0

I have a json array like this -:

"custom_attributes": [
            {
                "attribute_code": "description",
                "value": "Darkly sophisticated aromas take you into Siberia"},
            {
                "attribute_code": "color",
                "value": "6"
            },
            {
                "attribute_code": "options_container",
                "value": "container2"
            },
            {
                "attribute_code": "required_options",
                "value": "0"
            },
            {
                "attribute_code": "gift_message_available",
                "value": "2"
            },
            {
                "attribute_code": "brand",
                "value": "Molton Brown "
            },
            {
                "attribute_code": "supplier",
                "value": "Molton Brown "
            },
            {
                "attribute_code": "features",
                "value": "Twilight "
            }
        ]

I want to parse it through iterator. My keys are attribute_code and value.

Please help me for this parsing.

4
  • show your work please. Invalid JSON Commented Dec 14, 2017 at 7:52
  • @IntelliJAmiya JSON is valid. This is an array with same keys all over.I want to get, suppose "description." I dont want to write like getJsonObject(0). Instead i want iterator to find the attr code "description" and its specific value Commented Dec 14, 2017 at 7:56
  • Just write a for-loop. That's exactly what iterating means. Commented Dec 14, 2017 at 8:22
  • Leave I have done it through HashMap Commented Dec 14, 2017 at 8:25

1 Answer 1

1

Your JSON is invalid. It should be starting with [ so just remove the key "custom_attributes" used for json array.

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

3 Comments

I want to iterate inside array. Just ignore what is custom array.
Leave I have done it through HashMap
Actually problem is not with iteration, the json you posted here are invalid you can check that from codebeautify.org/jsonviewer, you first need to make a valid json, then you will be able to iterate that json array.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.