For this JSON:
{ "id": "3232", "data": [{ "data1": "555", "data2": "3243" }, { "data1": "888", " Data2 ":" 777 " }] }
We can parse this out:
Import Java.io.ioexception;import java.io.inputstream;import Java.io.reader;import Java.io.stringreader;import Com.google.gson.stream.jsonreader;import Android.app.activity;import Android.content.context;import Android.os.bundle;public class TestActivity1 extends Activity {@Overrideprotected void OnCreate (Bundle Savedinstancestate) {super.oncreate (savedinstancestate);p arseassertdata ();} public void Parseassertdata () {InputStream was = null;try {is = This.getassets (). Open ("Ss.json", context.mode_private); int length = is.available (); byte[] buffer = new Byte[length];is.read (buffer); String temp = new string (buffer); Reader response = new StringReader (temp.tostring ());p arseresponse (response);} catch (IOException ex) {ex.printstacktrace ();}} private void Parseresponse (reader response) throws IOException {Jsonreader reader = new Jsonreader (response); Reader.beginobject (); while (Reader.hasnext ()) {string name = Reader.nextname (); if ("id". Equals (name)) {String id = Reader.nextstring (); System.out.priNtln ("===id=" +id); else if (name.equals ("data")) {Reader.beginarray (); while (Reader.hasnext ()) {reader.beginobject (); String name1; while (Reader.hasnext ()) {name1 = Reader.nextname (); if (Name1.equals ("Data1")) {String S1 = reader.nextstring (); System.out.println ("===s1=" +s1); } else if (Name1.equals ("Data2")) {String s2 = reader.nextstring (); System.out.println ("===s2=" +s2); } else {reader.skipvalue (); }} reader.endobject ();} Reader.endarray ();} else {reader.skipvalue ();}} Reader.endobject (); Reader.close ();}}