user3404171
user3404171

Reputation: 113

How to combine/separate multiple json

i have a json which contains 2 json Objects

 {"cityList":[{"id":"2","cityName":"value"}]}
 {"subGuildList":[{"id":"340","guildId":"144","subGuildName":"value"}]}

now i want to combine 2 jsons object to one. What is the integration of the two json object above? and how can i to separate main json object with java or android?

Upvotes: 0

Views: 563

Answers (1)

royB
royB

Reputation: 12977

use Gson or some similar json converter. your Json in incorrect. if you say 1 json contains those 2 object then it's rep should be:

{
   "cityList":[{"id":"2","cityName":"value"}],
   "subGuildList":[{"id":"340","guildId":"144","subGuildName":"value"}]
}

Your POJO will be:

public class MyObject {
    private List<MyCity> cityList;
    private List<MyGuid> subGuidList;
}

public class MyCity {
    int id;
    String cityName;
}

Upvotes: 1

Related Questions