How can I parse the following to retrieve the following.
{"docs": [
"SolrDocument[{content_type=[text/plain], description=/mnt/sdcard/A.txt, id=4df6fa43-1a99-4475-bc5b-80dd0ab6d114, name=uploadedfile}]",
"SolrDocument[{content_type=[text/plain], description=asdf.png, id=9fb20d5d-cf39-4635-9a22-64560124809e, name=uploadedfile}]"]
}
I need to retrieve description into a string array and id to another string array.
I tried
a="docs"
JSONObject jobj = new JSONObject(line);
JSONArray IDS = (JSONArray) jobj.get(a);
This works but it returns an array of strings
The data you are trying to parse isn’t valid JSON, so you are now in RegEx territory. So reading each line out of the JSONArray you could extract what you are after like this:
This will print out: