I have a JSON array like this:
[
{
"name": "John",
"city": "chicago",
"age": "22"
},
{
"name": "John",
"city": "florida",
"age": "35"
},
{
"name": "Selena",
"city": "vegas",
"age": "18"
},
{
"name": "Selena",
"city": "Florida",
"age": "19"
}
]
I want to implement a function in Java which can take the JSON array, value and return a JSON String with all elements with passed value, Example:
public String returnSearch(JSONArray array, String searchValue){
// let us say if the searchValue equals John, this method
// has to return a JSON String containing all objects with
// the name John
}
Can anyone help me solve this issue? :)