I am using GSON library. I have a programm which returns JSON. JSON constructs and returns in this way:
Gson gson = new Gson();
//findNewComments returns List<Comment> comments
return gson.toJson(service.findNewComments(id,lastId));
So the result is:
[
{
"id": 43,
"entryId": 19,
"author": " m8w46",
"body": "mw86",
"date": "WED 9, 2011"
},
{
"id": 44,
"entryId": 19,
"author": " n7w4",
"body": "nw77w4",
"date": "WED 9, 2011"
}
]
But this array must be named as "comments"!
"comments": [
{
"id": 43,
"entryId": 19,
"author": " m8w46",
"body": "mw86",
"date": "WED 9, 2011"
},
{
"id": 44,
"entryId": 19,
"author": " n7w4",
"body": "nw77w4",
"date": "WED 9, 2011"
}
]
How can i do that?