json java code geeksforgeeks code example
Example 1: how to parse json in java
import org.json.*;
String jsonString = ... ;
JSONObject obj = new JSONObject(jsonString);
String pageName = obj.getJSONObject("pageInfo").getString("pageName");
JSONArray arr = obj.getJSONArray("posts");
for (int i = 0; i < arr.length(); i++)
{
String post_id = arr.getJSONObject(i).getString("post_id");
......
}
Example 2: Parse Json file and sort it by name, state code, district code in java
Parse Json file and sort it by name, state code, district code in java