I wish to get the JSON output as below which is two objects combined I think without using array. How can I get the following output?
{
"AppData": {
"status": "****",
"message": [
""
]
},
"Data": {
"token": "****"
}
}
I try the array way and if I get rid of the "[" and "]" then it will become invalid JSON.
My code as follows
public Response getSAppData(int id, String email, String password){
Map<String, AppData> AppDataHM = new HashMap<String, AppData>();
Map<String, Data> DataHM1 = new HashMap<String, Data>();
Data data = DataHM.get(new AppDataRequest (id, email, password));
List<String> message = new ArrayList<>();
message.add("");
AppDataHM.put("AppData", new AppData("success", message));
DataHM1.put("Data", data);
String AppDataJO = new Gson().toJson(AppDataHM);
String DataJO = new Gson().toJson(DataHM1);
String ADJODJOA = "["+AppDataJO+","+DataJO+"]";
return Response.status(200).entity(ADJODJOA).build();
}
And the output of my code as below
[
{
"AppData": {
"status": "success",
"message": [
""
]
}
},
{
"Data": {
"token": "token1"
}
}
]
Thank in advance for any reply and answer.