-3
{
"id": "1",
"name": "test1",
"data_city": "a:35:     {i:22;s:6:\"61,800\";i:23;s:6:\"61,800\";i:24;s:6:\"61,800\";i:25;s:6:\"61,800\" ;i:26;s:6:\"61,800\";i:27;s:6:\"61,800\";i:28;s:6:\"61,800\";i:29;s:6:\"61,800\";i:30;s:6:\"61,800\";i:31;s:6:\"61,800\";i:54;s:6:\"61,800\";i:16;s:6:\"61,800\";i:32;s:6:\"61,800\";i:52;s:6:\"61,800\";i:21;s:6:\"61,800\";i:33;s:6:\"61,800\";i:37;s:6:\"61,800\";i:34;s:6:\"61,800\";i:36;s:6:\"61,800\";i:38;s:6:\"61,800\";i:41;s:6:\"61,800\";i:35;s:6:\"61,800\";i:39;s:6:\"61,800\";i:40;s:6:\"61,800\";i:42;s:6:\"61,800\";i:44;s:6:\"61,800\";i:43;s:6:\"61,800\";i:46;s:6:\"61,800\";i:45;s:6:\"61,800\";i:47;s:6:\"61,800\";i:49;s:6:\"61,800\";i:53;s:6:\"61,800\";i:50;s:6:\"61,800\";i:48;s:6:\"61,800\";i:51;s:6:\"61,800\";}"
}

This is my json response i need to get data from string data_city

Sanjeet
  • 2,385
  • 1
  • 13
  • 22
  • 1
    Possible duplicate of [How to parse JSON in Android](http://stackoverflow.com/questions/9605913/how-to-parse-json-in-android) – Andrew Sun Oct 08 '16 at 14:25
  • That serialized data looks like it was created with PHP's `serialize()`. If you have control over how that data is printed, don't serialize at all and encode the entire array as JSON. – mwieczorek Oct 08 '16 at 15:01

1 Answers1

0

First of all, your JSON is not valid - probably a copy paste error.

Anyway, there are several ways to do this. One option is to use the built in JSONObject type:

String jsonString = "YOUR_JSON_STRING";
JSONObject objJSON = new JSONObject(jsonString);

String dataCity = objJSON.getString("data_city");

Hope this helps. Be sure to run your JSON String through a validation tool first. This one works nicely: https://jsonformatter.curiousconcept.com/

Justin Conroy
  • 376
  • 1
  • 12