Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

JSON Validation Showing as Duplicate Object warnings

I am new to Json, but I tried below json request.

{
    "recipes": [{
        "mr_id": 1,
        "ingredients": [{
            "ingredient_id": 2,
            "quantity": 4,
            "unit": "g",
            "nutrients": [{
                "nutrient_id": 1,
                "quantity": 2,
                "unit": "g"
            }],
            "ingredient_id": 3,
            "quantity": 4,
            "unit": "g",
            "nutrients": [{
                "nutrient_id": 2,
                "quantity": 2,
                "unit": "g"
            }]

        }],
        "mr_id": 2,
        "ingredients": [{
            "ingredient_id": 4,
            "quantity": 4,
            "unit": "g",
            "nutrients": [{
                "nutrient_id": 3,
                "quantity": 2,
                "unit": "g"
            }],
            "ingredient_id": 5,
            "quantity": 4,
            "unit": "g",
            "nutrients": [{
                "nutrient_id": 4,
                "quantity": 2,
                "unit": "g"
            }]

        }]

    }]
}

But when i place this in POSTMAN I am getting duplicate Object keys error , Even i checked in online jsonvalidator websites. Showing same duplicate warnings. Can some one please correct this?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

your json is not valid, each mr_id and each ingridient_id should be included into brackets {}

{
    "recipes": [
            {
            "mr_id": 1,
            "ingredients": [
              {
                    "ingredient_id": 2,
                    "quantity": 4,
                    "unit": "g",
                    "nutrients": [{
                        "nutrient_id": 1,
                        "quantity": 2,
                        "unit": "g"
                    }]
                },
                {
                    "ingredient_id": 3,
                    "quantity": 4,
                    "unit": "g",
                    "nutrients": [{
                        "nutrient_id": 2,
                        "quantity": 2,
                        "unit": "g"
                    }]
                }
            ]
        },
        {
            "mr_id": 2,
            "ingredients": [{
                    "ingredient_id": 4,
                    "quantity": 4,
                    "unit": "g",
                    "nutrients": [{
                        "nutrient_id": 3,
                        "quantity": 2,
                        "unit": "g"
                    }]
                },
                {
                    "ingredient_id": 5,
                    "quantity": 4,
                    "unit": "g",
                    "nutrients": [{
                        "nutrient_id": 4,
                        "quantity": 2,
                        "unit": "g"
                    }]
                }
            ]
        }
    ]
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading