parse JSON in Java

How to parse json in java .? Add org.json lib into your project 


public class PraseJSON {
    public static void main(String[] args) throws JSONException {
       String json = "{\n"
                + "   \"Name\": {\n"
                + "         \"Place\": \"Bangalore\",\n"
                + "         \"Age\": \"23\"\n"
                + "    }}";
              
               // + "}";

        PraseJSON classObject = new PraseJSON();
        JSONObject obj = new JSONObject(json);
        String name = obj.getJSONObject("Name").getString("Place");
        System.out.println("Name::"+name);


}}

Comments

Popular posts from this blog

Converting JSONArray into CSV file in java

Java Design pattern

Map class field to map