Wednesday, 15 September 2010

java - JSON Exception when trying to retrieve object string -


I am trying to retrieve the "Maxspeed" string from JSON I runs through this array, but When it reaches the "tag" object and tries to achieve the "maximized" value, then it gives an exception (below)

will anyone know why this is happening is?

Exception:

  org.json.JSONException: no value for maxspeed  

java:

  JSONObject parentObject = new JSONObject (result); JSONArray speedJSON = parentObject.getJSONArray ("element"); For (int i = 0; i   

< P> You are trying to get maxspeed from element , but it is not there. The object is in the element in the tag .

You want something like

  if (! Element IsNull ("tags")) {JSONObject tag = element.getJSONObject ("tags"); String maxspeed = tags.getString ("maxspeed"); TxtSpeed.setText (MaxSpeed ​​+ "here"); } Else {// your error handling here ...}  

No comments:

Post a Comment