java - can't split json string as parameter in jsonarray -


i have code , tried getting items string

but it's failed

i have used eclipse ide

i have parsing json string remote host

package selectdb;  import java.io.*; import java.net.url; import java.net.urlconnection; import java.sql.*; import java.text.dateformat; import java.text.simpledateformat; import java.util.date; import java.util.timer; import java.util.timertask; import org.json.simple.jsonarray; import org.json.simple.jsonobject; import org.json.simple.parser.jsonparser; import org.json.simple.parser.parseexception;  public class selectdb {     public static void main(string[] args) throws ioexception, parseexception   {       string line;       string s = "";        url u = new url("http://192.168.3.1/android/select.php");       urlconnection c = u.openconnection();       inputstream r = c.getinputstream();       bufferedreader reader = new bufferedreader(new inputstreamreader(r));       for(; (line = reader.readline()) != null;)           {               s+=line;           }       system.out.println(s);       try{       jsonobject jobject  = new jsonobject(s);       string projecname=(string) jobject.get("name");       system.out.print(projecname);      }catch(exception e)      {}       }  } 

the result json string

{"result" : "true" , "messages" : [{"id":"866343023633578","latitute":"27","longitude":"31","number_phone":"01113171374"},{"id":"352168066354050","latitute":"27","longitude":"31","number_phone":"202222"},{"id":"50","latitute":"50","longitude":"100","number_phone":"50"},{"id":"110","latitute":"50","longitude":"50","number_phone":"110"},{"id":"120","latitute":"27","longitude":"31","number_phone":"120"},{"id":"130","latitute":"28","longitude":"29","number_phone":"120"},{"id":"140","latitute":"30","longitude":"40","number_phone":"140"},{"id":"800","latitute":"60","longitude":"30","number_phone":"800"},{"id":"353629054230064","latitute":"70","longitude":"80","number_phone":"120"}]} 

please me

thanks

you have parse json string jsonobject using jsonparser

you cannot parameterise jsonobject string.

so have do:

jsonparser parser = new jsonparser(); jsonobject jobject=(jsonobject)parser.parse(jsonstr); string projecname=(string) jobject.get("name"); 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -