I have a JSON String that I am parsing, and I want to retrieve the value of the field "pr_num". I am getting this error:
JSONObject["pr_num"] is not a JSONArray.
My code is below:
JSONObject obj = new JSONObject(jsonString);
JSONArray data = obj.getJSONArray("pr_num");
JSONObject obj1= data.getJSONObject(0);
System.out.println("JSON CONTENTS ARE"+obj1.getString("pr_num"));
I want to get values for pr_num
field which are 690052
and null
.
jsonString is mention below
[{
"executed_by": "vishnuc",
"testplan_id": 17372,
"pr_num": "690052"
},
{
"executed_by": "kkavitha",
"testplan_id": 17372,
"pr_num": null
}]