I am trying to read JSON file from asset folder. But I get the following exceptionorg.json.JSONException: Expected literal value at character 550
I searched lot of stuff but didn't find anything relative. Here is my JSON file.
I find JSON object on 550 is "names": ["Santosh","Sandip","Arvind"],
. I am trying to solve it but don't know what happens in my code.
Here is my code.
I also debug my code but when control goes on JSONObject jsonObject = new JSONObject(text);
it throw exception and goes in first catch block.
Please give me any reference or hint to solve this problem.
Any help appreciated.
your JSON is invalid.
your JSON should look like this
{
"resultCount": 3,
"SearchedTerm": "Wada Pav",
"results": [
{
"locationname": "Mahableshwar Hotel",
"locationid": "12345",
"locationaddress": "baner, Pune",
"dishrating": "4",
"dishname": "Wada Pav",
"dishid": "234",
"dishcategory": "Snacks",
"dishnotes": "Spicy Wada Pav",
"dishpreviewurl": "http://xxx.yyy.zzz/mahableshwar/1.jpg",
"dishtotalvotes": "9999",
"friendslistvoted": {
"friendscount": "3",
"names": [
"Santosh",
"Sandip",
"Arvind"
]
},
"dishimageurl": "http://xxx.yyy.zzz/mahableshwar/2.jpg",
"mylastrating": "4"
}
]
}
try using a JSON validator before using it (like JSLint).
I'm using following to get standard JSON format. This one is better.
public static String convertStandardJSONString(String data_json) {
data_json = data_json.replaceAll("\\\\r\\\\n", "");
data_json = data_json.replace("\"{", "{");
data_json = data_json.replace("}\",", "},");
data_json = data_json.replace("}\"", "}");
return data_json;
}
I use jsoneditoronline online tool that works pretty good.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With