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);
}}
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
Post a Comment