Android: unable to retrieve data from json -


I am getting an id of some event for this activity from previous activity and passing this ID in the current activity URL The name of the city that is being found in the URL is my code.

  string s = getIntent (). GetStringExtra ("AR"); Try {HttpPost hpost = New HTTP Post ("xxxxxxxxxxxxxxxxx / id"); HttpResponse response = login.client.execute (hpost); & Lt; NameValuePair & gt; NameValuePairs = New ArrayList & lt; NameValuePair & gt; (1); NameValuePairs.add (New BasicNameValuePair ("id", s)); Hpost.setEntity (new UrlEncodedFormEntity (nameValuePairs)); String re = entityUtils.toString (response.getEntity ()); System.out.print (ri); JSONObject Root = New JSONObject (Re); EveState.setText (root.getString ("cityname")); } Hold (exception e) {Log.e ("exvcx", "Error obtaining data" + e.toString ()); }   

The exception that I'm getting is no value for the city name . I think I am unable to pass the ID to this URL..Please tell this the right way? If so, then provide the solution to the problem otherwise please correct me where I am doing wrong. Thank you. " "Position": "try" entry "", "response": 1, "response": "try to enter", "phnumber": ["id": "73", "name": "dangerous", "address": "rigdog", "location" : "2467568", "created": "2012-07-11 06:24:31", "picture": "4ffd626f021487.45227344.jpg", "block": "n" "destroyed": "n" "Cityname": "juno", "statename": "alaska", "interestname": "comic", "user name": "princeb", "EVENTDATE": "2012- 07-13 15:45:29, "Format": "July 13, 2012"}], "ImageWith": 1024, "ImageHit": 1024}

Please see the answer to the question below

I have this question "Country Code": ["Country Code": "00", "Country Name": "World Wide"}, {"Country Code:", "Country", "Country Name" "Korea" }]}

Below I am bringing the details of the country

  JSONObject json = new JSONObject (jsonstring); JSONArray nameArray = json.names (); JSONArray valArray = json.toJSONArray (nameArray); JSONArray valArray1 = valArray.getJSONArray (1); ValArray1.toString (). replace the ("[", ""); ValArray1.toString (). Change ("]", ""); Int len ​​= valArray1.length (); For (int i = 0; i & lt; valArray1.length (); i ++) {country country = new country (); JSONObject arr = valArray1.getJSONObject (i); Country.setCountryCode (arr.getString ("Country Code")); Country.setCountryName (arr.getString ("Country Name")); ArrCountries.add (country); }    

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -