find value in json code example
Example 1: get value json python
print(json_object_string)
OUTPUT
{"id":"20", "name":"Bob"}
json_object = json.loads(json_object_string)
print(json_object["name"])
OUTPUT
Bob
Example 2: jsonarray find
JSONArray event_values = opoutput.getJSONArray("DISPLAY_VALUES");
JSONArray event_codes = opoutput.getJSONArray("VALUES");
List<String> valueList = new ArrayList<String>();
List<String> displayList = new ArrayList<String>();
for(int i=0;i<event_codes.length();i++){
valueList.add(event_codes.getString(i));
displayList.add(event_values.getString(i));
}
int index = valueList.indexOf("ACCPT");
String valueToDisplay = displayList.get(index);