Pushan
Pushan

Reputation: 480

Android json parsing

how to parse only this type of json arrary

[{'name':'john', 'age': 44}, {'name':'Alex','age':11}]

where i can't do something like this:

JSONArray DataListArray = jObject.getJSONArray("???");

Upvotes: 0

Views: 960

Answers (2)

Oleg
Oleg

Reputation: 221997

The string like

[{'name':'john', 'age': 44}, {'name':'Alex','age':11}]

is wrong JSON. You can validate JSON here. Correct will be

[{"name":"john", "age": 44}, {"name":"Alex","age":11}]

Upvotes: 1

Ravi Vyas
Ravi Vyas

Reputation: 12365

You can use the string to initialize the JSON array.

String json = "[{'name':'john', 'age': 44}, {'name':'Alex','age':11}]";
JSONArray json = new JSONArray(json);

Upvotes: 2

Related Questions