JSON to Object and Array in Java

Try this snippet to convert JSON text into object and/or array in Java:

JSONObject object = new JSONObject(jsontext);
JSONArray array = jsonObj.getJSONArray("somearray");
for (int i = 0; i < somearray.length(); i++) {
	JSONObject item = somearray.getJSONObject(i);
	String somevalue = item.getString("somekey");
}

jsontext is your JSON text.

Getting boored? Why not playing a game?

Power Block

Tiki Solitaire

Pet Connect

Cake Shop

Jewels Blitz 3

Forest Match

Bike Racing

Aquador

Solitaire Swift

Bubble Shooter Classic HD

Black and white snake

Leave a Reply

Your email address will not be published. Required fields are marked *