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

Unable to access json array data

i am trying to access data from a Json file but i can not retrive data from level 2.

let me paste my json here.

{
    "success": true,
    "data": {
        "bookings": [
            {
                "id": 1,
                "customer_id": 1
            }
        ]
    },
    "message": "Current booking list"
}

i want to access id from within bookings but i only can get data of success and message by doing jsonresponse.success is returns "true" but when i do jsonresponse.data.bookings.id it gives error. please help

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 :

jsonresponse.data.bookings is an Array, so if you need to read id of first element you should use jsonresponse.data.bookings[0].id

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