I'm creating a JSON file with GSON, but the arrays doesn't have names.
My result:
[
{
"name": Jonh,
"date": "Feb 16, 2066",
"hour": "10:15:00 PM"
},
{
"name": Maria,
"date": "Feb 16, 2066",
"hour": "10:15:00 PM"
}
]
What I need:
{
"users": {
"user": [
{
"name": John,
"date": "Feb 16, 2066",
"hour": "10:15:00 PM"
},
{
"name": Maria,
"date": "Feb 16, 2066",
"hour": "10:15:00 PM"
}
]
}
}
Someone knows how can I put name an arrays?
--EDIT
I'm using this code for generate my JSON file.
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("user/list")
public String getListUsers() throws Exception {
List<Object> list;
UserDAOImpl daoUser = new UserDAOImpl();
list = daoUser.listAllUsers();
Gson g = new Gson();
return g.toJson(list);
}
{}) using a Java class, and a JSON array ([]) using aList, so what's the difficulty in creating more Java objects to create more JSON objects? I don't see the problem.