Exactly the same question has been asked here: JAX-RS - JSON without root node But the solution doesn't work for me because my server doesn't have any other interfaces besides REST, thus file WEB-INF/web.xml doesn't exists. Below is the original question:
I have a restfull webservice, and the response is:
{
"cities": [
{
"id": "1",
"name": "City 01",
"state": "A1"
},
{
"id": "2",
"name": "City 02",
"state": "A1"
}
]
}
But I want this
[
{
"id": "1",
"name": "City 01",
"state": "A1"
},
{
"id": "2",
"name": "City 02",
"state": "A1"
}
]
How I can configure JAX-RS to produces JSON without root node using only JAX-RS feature, and not implementation specific feature? My code needs to be portable accross any appserver.
Thanks