-4

I have a JSON data and I want to a count two the same JSON object value, but I don't know how to add it

{
    "data": [
        {
            "ID": 1,
            "country": "Indonesia",
            "city": "Jakarta",
        },
        {
            "ID": 2,
            "country": "Indonesia",
            "city": "Jakarta",
        },
        {
            "ID": 3,
            "country": "Indonesia",
            "city": "Medan",
        },
        {
            "ID": 4,
            "country": "USA",
            "city": "New york",
        },

Output like: -

enter image description here

2

1 Answer 1

0

Your question is wrong because your objects are not actually same, the value of id is different in both the objects, so it makes it different, you can check your values and compare them on that values, so in your case, you can do something like this -> obj1.country.equalsTo(obj2.cpuntry) && obj1.city.equalsTo(obj2.city) and mark it as same

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.