EDITED I didn't explain myself properly, so I'll ask again properly.
I have array list of json object. My json contain 13000 objects , each object contains a few values. In some cases, one of the values in the objects is the same. For example:
That what i have now:
public void readData() {
String json_string = null;
try {
InputStream inputStream = getActivity().getAssets().open("garages.json");
int size = inputStream.available();
byte[] buffer = new byte[size];
inputStream.read(buffer);
inputStream.close();
json_string = new String(buffer, StandardCharsets.UTF_8);
Gson gson = new Gson();
garage = gson.fromJson(json_string, Garage.class);
//In this loop I'm checking address and if it equal to current user address , I'm add this object to Array list.
for (int i = 0; i < 13476; i++) {
if (garage.getGarage().get(i).garageCity.equals(AddressSingleton.getInstance().getCurrentAddress())) {
garageObjects.add(garage.getGarage().get(i));
Log.d("TheDataIS", "readData: " + garage.getGarage().get(i).garageName);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
If you look at the JSON file, you can see that the name in the first and second garage is the same, but another value garage_code is different. In this case I do not want to add both objects to the array.
{
"garage" : [
{
"garage_code":16,
"garage_name": "New York Garage",
"phone_number": "123123",
"city":"New York"
},{
"garage_code":21,
"garage_name": "New York Garage",
"phone_number": "123123",
"city":"New York"
},{
"garage_code":51,
"garage_name": "My Garage",
"phone_number": "089898",
"city":"Some city"
},...
For this json file , i want that only the first and third objects will be added to the Array.