0

I experiment with retrieving JSON objects via my custom scripts and I noticed it works when the object is in the following format:

[
  {
    "id": 1,
    "name": "Leanne Graham",

but some apps deliver the object without the outer square brackets, as in:

  {
    "id": 1,
    "name": "Leanne Graham",

This one does not work. I am not that familiar witj JSON so unsure which one is correct or hiw thi is called/used.

John V
  • 4,855
  • 15
  • 39
  • 63

1 Answers1

0

The [] indicates a collection. You can For Each over (with Item as Object i.e. For Each Item in Collection) this or index into it

e.g. json(1) will give first dictionary item in collection

The {} indicates a dictionary which you can For Each over the keys of (with Key as Variant) or access individual items by dict(key)

You may need branched logic using a test for TypeName(json...) for example to determine which parent object you are working with.

For info see this answer.

QHarr
  • 83,427
  • 12
  • 54
  • 101