I have a web servlet that returns a json which is stored in my bb mobile app as string in json format….
Now I want to parse the string to extract values from it…
using
JSONObject jsobject = new JSONObject(jsonString);
returns an error:
json must start with {
My JSON generated is in this format
[
{"LASTNAME":"akre","FIRSTNAME":"swapnil"},
{"LASTNAME":"akre","FIRSTNAME":"swapnil"},
{"LASTNAME":"akre","FIRSTNAME":"swapnil"}
]
which is corect format as verified by jsonlint.com….
yes, json must start with
{and end with}, what you can do is you put your json array in{}, so it will be parsed correctly. JsonLint parses the partial json as well thats why it is showing it as correct. You can try like followingyes, json must start with
{and end with}, what you can do is you put your json array in{}, so it will be parsed correctly as jsonobject. JsonLint parses the partial json as well thats why it is showing it as correct