android - How to read a Json inside a Json in java? -


i'm trying data of json. can see first element have json inside of json.

{    "client":{       "colour":"aabb11",       "height":200,       "xpos":0,       "packages":"com.samsung.incallui",       "events":[          {             "action":"hide",             "class":"com.android.textview",             "type":"2"          },          {             "colour":"00ff00",             "action":"show"          }       ],       "width":600,       "ypos":20    },    "map":" {red=blue, yellow=brown}",    "country":"it" } 

i json from:

request request = new request.builder().url(init_url).post(formbody).build(); response response = client.newcall(request).execute(); 

i'm trying this, don't work (give me jsonsyntaxexception):

... jsonarray ja = new jsonarray(response.body().string()); (int = 0; < ja.length(); i++) {     jsonobject jo = ja.getjsonobject(i);      string client = jo.getstring("client");     string xpos = jo.getstring("height");     string packages = jo.getstring("xpos");     string events = jo.getstring("packages");     ... } ...  

the first element, "client" object not array. try

jsonobject ja= new jsonobject(response.body().string()); 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -