android - Java HttpsURLConnection response JSON array -


i have been receiving json objects response httpsurlconnection. have been using parse response.

objectmapper map = new objectmapper(); jsonnode node = map.readtree(conn.getinputstream()); 

this has been working fine me receiving arrays. how can parse them?

this example of response receive:

"value": [1 ] 0: { "id": "2135125324" "name": "john" "2ndname": null "lastname": "james" }

please try if using asynctask write below code

private void yourfunction() {      class yourclass extends asynctask<string, void, string>     {           @override         protected void onpreexecute() {             super.onpreexecute();         }          @override         protected void onpostexecute(string s) {             super.onpostexecute(s);              try {                 jsonobject jsonobj = new jsonobject(s);                 user = jsonobj.getjsonarray("value");                 jsonobject c = user.getjsonobject(0);                 string profile = c.getstring("id");                 string name = c.getstring("name");                } catch (jsonexception e) {                 e.printstacktrace();             }           }          @override         protected string doinbackground(string... params) {             string s = params[0];             bufferedreader bufferedreader = null;             try {                 url url = new url("your url string");                 httpurlconnection con= (httpurlconnection) url.openconnection();                 bufferedreader=new bufferedreader(new inputstreamreader(con.getinputstream()));                 string result;                 result = bufferedreader.readline();                 return result;             }             catch (exception e) {                 return null;             }         }     }     yourclass lu=new yourclass();     lu.execute(); } 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -