I was using WOT(web of trust) api.In this, i am getting response in this format,
process( {
"www.google.com": {
"target": "google.com",
"0": [ 95, 84 ],
"1": [ 95, 84 ],
"2": [ 95, 84 ],
"4": [ 93, 78 ],
"categories": {
"501": 92
}
}
} )
I am very confused to extract the data string from this format of JSON. I searched a lot but could not find any way.
I want to extract from categories... means I want to save '502' value.
Problem : JSON Objects starts with "{" and ends with "}", the response you're getting is not a correct JSON Format.
Analysis : Why? you might ask, the response started with p
char from process
, and ends with )
char, instead of "}".
Solution : To fix the json, we will need to remove the process (
and )
string, so that the response can be parsed as JSON.
Hint : Use String.replace()
method to replace the unwanted string with empty string ""
, more information here and here
Hope this helps, and Good Luck! ^^
Reid
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.