0

I have one JSON that looks like below, in this JSON I have one object and inside this object, I have a list of other objects, so how to read the object list from the main object foo also the insider list is dynamic

this is my JSON

foo: {
    "foo1": {
        "end": 12,
        "start": 0
    },
    "foo2": {
        "end": 7,
        "start": 0
    },
    "foo3": {
        "end": 12,
        "start": 8
    },
    {
    ...
    },
    ....
}
1
  • 1
    You can use GSON to serialization/deserialization that json into an object link Commented Oct 13, 2022 at 13:53

1 Answer 1

1

Just pass the json to variable and then access the data using hierarchy.

var obj = {foo: {
"foo1": {
    "end": 12,
    "start": 0
},
"foo2": {
    "end": 7,
    "start": 0
},
"foo3": {
    "end": 12,
    "start": 8
}



 obj.foo.foo1 //This will show the obj foo1
 obj.foo //this will show the obj.foo
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.