Rectangle 27 0

arrays String to jsonobject in java?


Note
Rectangle 27 0

arrays String to jsonobject in java?


JsonParser jsonParser = new JsonParser();
JsonElement element = jsonParser.parse(your json string);
Note
Rectangle 27 0

arrays String to jsonobject in java?


1
ABC
2
PQR
3
XYZ
String jsonStr = "[{\"No\":\"1\",\"Name\":\"ABC\"},{\"No\":\"2\",\"Name\":\"PQR\"},{\"No\":\"3\",\"Name\":\"XYZ\"}]";

   JSONArray array = new JSONArray(jsonStr); 

    for(int i=0; i<array.length(); i++){
        JSONObject jsonObj  = array.getJSONObject(i);
        System.out.println(jsonObj.getString("No"));
        System.out.println(jsonObj.getString("Name"));
    }
Note