Home > Mobile >  How to get all lists available on a json Array with google Apps script
How to get all lists available on a json Array with google Apps script

Time:08-31

I'm a beginner in GAS and i'm seeking for help to complete my script, my aim is to get data from a Public Api, actually i was able to write a code to retrieve Data, but i'm still not able to pull all the data from arrays, for example :

"isLabeledBy": [
                {
                    "attributedAt": null,
                    "endDate": null,
                    "detail": [],
                    "isConceptualizedBy": {
                        "code": "10055",
                        "pictureUrl": "https://smedia.alkemics.com/api/1/concept/10055/picture/logo/original.png",
                        "description": "",
                        "label": "Cosmebio"
                    },
                    "value": null,
                    "startDate": null
                },
                {
                    "attributedAt": null,
                    "endDate": null,
                    "detail": [],
                    "isConceptualizedBy": {
                        "code": "80002",
                        "pictureUrl": "https://smedia.alkemics.com/api/1/concept/80002/picture/logo/original.png",
                        "description": "",
                        "label": "Triman"
                    },
                    "value": null,
                    "startDate": null
                },
                {
                    "attributedAt": null,
                    "endDate": null,
                    "detail": [],
                    "isConceptualizedBy": {
                        "code": "ECOCERT_COSMETIQUE_ECO",
                        "pictureUrl": "https://smedia.alkemics.com/api/1/concept/100230755/picture/logo/original.png",
                        "description": "",
                        "label": "Ecocert - Cosmétique Écologique"
                    },
                    "value": null,
                    "startDate": null
                },
                {
                    "attributedAt": null,
                    "endDate": null,
                    "detail": [],
                    "isConceptualizedBy": {
                        "code": "19095",
                        "pictureUrl": "https://smedia.alkemics.com/api/1/concept/19095/picture/logo/original.png",
                        "description": "",
                        "label": "European Organic Agriculture"
                    },
                    "value": null,
                    "startDate": null
                },
                {
                    "attributedAt": null,
                    "endDate": null,
                    "detail": [],
                    "isConceptualizedBy": {
                        "code": "72117",
                        "pictureUrl": "https://smedia.alkemics.com/api/1/concept/72117/picture/logo/original.png",
                        "description": "",
                        "label": "Concours des vins Elle à Table 2017 - Or"
                    },
                    "value": null,
                    "startDate": null
                }
            ],

Here we have a json Array, i need the data corresponding to the attribute label, but my script allows me to get only the first one in the array but not the four others(I can have the others by changing the index in my script but not the fifth at the same time).

the first one : "label": "Cosmebio"

the four others: "label": "Concours des vins Elle à Table 2017 - Or" "label": "European Organic Agriculture" "label": "Ecocert - Cosmétique Écologique" "label": "Triman"

picture of my script:enter image description here

I would like to display the values in the picture in one cell.

  • Related