How do I parse Json data when the Json response data is returned in nested Json object form.
I looked at this post which shows how to get only one piece of data. As I want whole data set it is not useful for me.
It said:
JSONObject jMainObject = null;
try {
jMainObject = new JSONObject(jsonString);
JSONObject apiGroupsObject = jMainObject.getJSONObject("apiGroups");
JSONObject affiliateObject = apiGroupsObject.getJSONObject("affiliate");
JSONObject apiListingsObject = affiliateObject.getJSONObject("apiListings");
JSONObject bags_wallets_beltsObject = apiListingsObject.getJSONObject("bags_wallets_belts");
JSONObject availableVariantsObject = bags_wallets_beltsObject.getJSONObject("availableVariants");
JSONObject versionObject = availableVariantsObject.getJSONObject("v0.1.0");
System.out.println(versionObject);
} catch (JSONException e) {
e.printStackTrace();
}
The Json returned data which I want to parse is coming from here.
Can anyone help me to solve my problem about how to parse this type of data as I’m new so I don’t know how to parse nested Json object data. Perhaps I can use Gson for it? But I also don't know how to use that.