Tuesday, 15 April 2014

android - How to parse my json data? -


I'm starting in Android and I want to get data from the server and show data in the data view. I get the data correctly from the server and show the result in toast, but my data is:

  [{"countryname": "China", "calculation" : "200"}]  

How can I parse that result in this block?
For example: countryname = China

  @Override protected void OnPostExecute (string result) {//Toast.makeText (getBaseContext (), "Data sent! ", Toast.LNGTH_LONG). Show (); //Log.d (I have my backup backup: "result.toString ()); try {JSONObject jsonObj = new JSONObject (result);} hold (JasonXExtension) {e.printStackTrace ();}}  

Please do not show me the link to the tutorial or any other site, please write your code. Thanks for all.

  protected void onPostExecute (string result) {//Toast.makeText (GetBaseContext ()," Data Sent! ", Toast.LNGTH_LONG) Show (); // Log. D (i have my backup backup: ", result.toString ()); Try {JSONArray jsonArray = New JSONArray (Results); For (int i = 0; i & lt; jsonArray.length (); i ++) {JSONObject jsonObj = jsonArray.getJSONObject (i); String country = jsonObj.getString ("country name"); String calculation = jsonObj.getString ("Calculate"); }} Hold (JasonX Express E) {e.printStackTrace (); }}  

No comments:

Post a Comment