Searching through JSON data

Hello,

I have now tried for hours, but I do not understand it. I'm not a developer, otherwise I'll help me regex. Here I don't get any further.

Maybe a look from you is enough.

Context: I want to load the objects - here Sticky Notes from a MiroBoard. I do this with cURL.

I get this data back.

I want to read the ID and text of the sticky notes in a loop. I am looking for a placeholder text e.g. "Risk1" in the JSON file. From this I need the ID of the object. If I have the ID and the text, I can change the sticky note in the text.

{
  "size": 10,
  "limit": 10,
  "total": 44,
  "data": [
    {
      "id": "3458764543361298328",
      "type": "sticky_note",
      "links": {
        "self": "https://api.miro.com/v2/boards/uXjVPybXf6M=/sticky_notes/3458764543361298328"
      },
      "parent": {
        "links": {
          "self": "https://api.miro.com/v2/boards/uXjVPybXf6M=/items/3458764543319467218"
        },
        "id": "3458764543319467218"
      },
      "createdAt": "2023-01-16T09:09:24Z",
      "createdBy": {
        "id": "3074457346407430089",
        "type": "user"
      },
      "data": {
        "content": "<p>Risk1</p>",
        "shape": "rectangle"
      },
      "geometry": {
        "width": 189,
        "height": 123.12
      },
      "modifiedAt": "2023-01-16T15:27:12Z",
      "modifiedBy": {
        "id": "3074457346407430089",
        "type": "user"
      },
      "position": {
        "x": 207.24238588207027,
        "y": 1130.742576946217,
        "origin": "center",
        "relativeTo": "parent_top_left"
      },
      "style": {
        "fillColor": "light_yellow",
        "textAlign": "center",
        "textAlignVertical": "middle"
      }
    },
    {
      "id": "3458764543361298329",
      "type": "sticky_note",
      "links": {
        "self": "https://api.miro.com/v2/boards/uXjVPybXf6M=/sticky_notes/3458764543361298329"
      },
      "parent": {
        "links": {
          "self": "https://api.miro.com/v2/boards/uXjVPybXf6M=/items/3458764543319467218"
        },
        "id": "3458764543319467218"
      },
      "createdAt": "2023-01-16T09:09:24Z",
      "createdBy": {
        "id": "3074457346407430089",
        "type": "user"
      },
      "data": {
        "content": "Risk2",
        "shape": "rectangle"
      },
      "geometry": {
        "width": 189,
        "height": 123.12
      },
      "modifiedAt": "2023-01-16T15:27:12Z",
      "modifiedBy": {
        "id": "3074457346407430089",
        "type": "user"
      },
      "position": {
        "x": 441.2837751426,
        "y": 1130.742576946217,
        "origin": "center",
        "relativeTo": "parent_top_left"
      },
      "style": {
        "fillColor": "light_yellow",
        "textAlign": "center",
        "textAlignVertical": "middle"
      }
    },
    {
      "id": "3458764543361298330",
      "type": "sticky_note",
      "links": {
        "self": "https://api.miro.com/v2/boards/uXjVPybXf6M=/sticky_notes/3458764543361298330"
      },
      "parent": {
        "links": {
          "self": "https://api.miro.com/v2/boards/uXjVPybXf6M=/items/3458764543319467218"
        },
        "id": "3458764543319467218"
      },
      "createdAt": "2023-01-16T09:09:24Z",
      "createdBy": {
        "id": "3074457346407430089",
        "type": "user"
      },
      "data": {
        "content": "Risk3",
        "shape": "rectangle"
      },
      "geometry": {
        "width": 189,
        "height": 123.12
      },
      "modifiedAt": "2023-01-16T15:27:12Z",
      "modifiedBy": {
        "id": "3074457346407430089",
        "type": "user"
      },
      "position": {
        "x": 675.3251644031302,
        "y": 1130.742576946217,
        "origin": "center",
        "relativeTo": "parent_top_left"
      },
      "style": {
        "fillColor": "light_yellow",
        "textAlign": "center",
        "textAlignVertical": "middle"
      }
    },
    {
      "id": "3458764543361298331",
      "type": "sticky_note",
      "links": {
        "self": "https://api.miro.com/v2/boards/uXjVPybXf6M=/sticky_notes/3458764543361298331"
      },
      "parent": {
        "links": {
          "self": "https://api.miro.com/v2/boards/uXjVPybXf6M=/items/3458764543319467218"
        },
        "id": "3458764543319467218"
      },
      "createdAt": "2023-01-16T09:09:24Z",
      "createdBy": {
        "id": "3074457346407430089",
        "type": "user"
      },
      "data": {
        "content": "Risk4",
        "shape": "rectangle"
      },
      "geometry": {
        "width": 189,
        "height": 123.12
      },
      "modifiedAt": "2023-01-16T15:27:12Z",
      "modifiedBy": {
        "id": "3074457346407430089",
        "type": "user"
      },
      "position": {
        "x": 909.3665536636702,
        "y": 1130.742576946217,
        "origin": "center",
        "relativeTo": "parent_top_left"
      },
      "style": {
        "fillColor": "light_yellow",
        "textAlign": "center",
        "textAlignVertical": "middle"
      }
    },
    {
      "id": "3458764543361298332",
      "type": "sticky_note",
      "links": {
        "self": "https://api.miro.com/v2/boards/uXjVPybXf6M=/sticky_notes/3458764543361298332"
      },
      "parent": {
        "links": {
          "self": "https://api.miro.com/v2/boards/uXjVPybXf6M=/items/3458764543319467218"
        },
        "id": "3458764543319467218"
      },
      "createdAt": "2023-01-16T09:09:24Z",
      "createdBy": {
        "id": "3074457346407430089",
        "type": "user"
      },
      "data": {
        "content": "Risk5",
        "shape": "rectangle"
      },
      "geometry": {
        "width": 189,
        "height": 123.12
      },
      "modifiedAt": "2023-01-16T15:27:12Z",
      "modifiedBy": {
        "id": "3074457346407430089",
        "type": "user"
      },
      "position": {
        "x": 1143.4079429242001,
        "y": 1130.742576946217,
        "origin": "center",
        "relativeTo": "parent_top_left"
      },
      "style": {
        "fillColor": "light_yellow",
        "textAlign": "center",
        "textAlignVertical": "middle"
      }
    },
    {
      "id": "3458764543361298333",
      "type": "sticky_note",
      "links": {
        "self": "https://api.miro.com/v2/boards/uXjVPybXf6M=/sticky_notes/3458764543361298333"
      },
      "parent": {
        "links": {
          "self": "https://api.miro.com/v2/boards/uXjVPybXf6M=/items/3458764543319467218"
        },
        "id": "3458764543319467218"
      },
      "createdAt": "2023-01-16T09:09:24Z",
      "createdBy": {
        "id": "3074457346407430089",
        "type": "user"
      },
      "data": {
        "content": "Risk6",
        "shape": "rectangle"
      },
      "geometry": {
        "width": 189,
        "height": 123.12
      },
      "modifiedAt": "2023-01-16T15:27:12Z",
      "modifiedBy": {
        "id": "3074457346407430089",
        "type": "user"
      },
      "position": {
        "x": 1377.44933218473,
        "y": 1130.742576946217,
        "origin": "center",
        "relativeTo": "parent_top_left"
      },
      "style": {
        "fillColor": "light_yellow",
        "textAlign": "center",
        "textAlignVertical": "middle"
      }
    },
    {
      "id": "3458764543361298334",
      "type": "sticky_note",
      "links": {
        "self": "https://api.miro.com/v2/boards/uXjVPybXf6M=/sticky_notes/3458764543361298334"
      },
      "parent": {
        "links": {
          "self": "https://api.miro.com/v2/boards/uXjVPybXf6M=/items/3458764543319467218"
        },
        "id": "3458764543319467218"
      },
      "createdAt": "2023-01-16T09:09:24Z",
      "createdBy": {
        "id": "3074457346407430089",
        "type": "user"
      },
      "data": {
        "content": "Risk7",
        "shape": "rectangle"
      },
      "geometry": {
        "width": 189,
        "height": 123.12
      },
      "modifiedAt": "2023-01-16T15:27:12Z",
      "modifiedBy": {
        "id": "3074457346407430089",
        "type": "user"
      },
      "position": {
        "x": 1611.4907214452683,
        "y": 1130.742576946217,
        "origin": "center",
        "relativeTo": "parent_top_left"
      },
      "style": {
        "fillColor": "light_yellow",
        "textAlign": "center",
        "textAlignVertical": "middle"
      }
    },
    {
      "id": "3458764543361298335",
      "type": "sticky_note",
      "links": {
        "self": "https://api.miro.com/v2/boards/uXjVPybXf6M=/sticky_notes/3458764543361298335"
      },
      "parent": {
        "links": {
          "self": "https://api.miro.com/v2/boards/uXjVPybXf6M=/items/3458764543319467218"
        },
        "id": "3458764543319467218"
      },
      "createdAt": "2023-01-16T09:09:24Z",
      "createdBy": {
        "id": "3074457346407430089",
        "type": "user"
      },
      "data": {
        "content": "Risk8",
        "shape": "rectangle"
      },
      "geometry": {
        "width": 189,
        "height": 123.12
      },
      "modifiedAt": "2023-01-16T15:27:12Z",
      "modifiedBy": {
        "id": "3074457346407430089",
        "type": "user"
      },
      "position": {
        "x": 1845.5321107058012,
        "y": 1130.742576946217,
        "origin": "center",
        "relativeTo": "parent_top_left"
      },
      "style": {
        "fillColor": "light_yellow",
        "textAlign": "center",
        "textAlignVertical": "middle"
      }
    },
    {
      "id": "3458764543361298336",
      "type": "sticky_note",
      "links": {
        "self": "https://api.miro.com/v2/boards/uXjVPybXf6M=/sticky_notes/3458764543361298336"
      },
      "parent": {
        "links": {
          "self": "https://api.miro.com/v2/boards/uXjVPybXf6M=/items/3458764543319467218"
        },
        "id": "3458764543319467218"
      },
      "createdAt": "2023-01-16T09:09:24Z",
      "createdBy": {
        "id": "3074457346407430089",
        "type": "user"
      },
      "data": {
        "content": "Risk9",
        "shape": "rectangle"
      },
      "geometry": {
        "width": 189,
        "height": 123.12
      },
      "modifiedAt": "2023-01-16T15:27:12Z",
      "modifiedBy": {
        "id": "3074457346407430089",
        "type": "user"
      },
      "position": {
        "x": 2079.573499966335,
        "y": 1130.742576946217,
        "origin": "center",
        "relativeTo": "parent_top_left"
      },
      "style": {
        "fillColor": "light_yellow",
        "textAlign": "center",
        "textAlignVertical": "middle"
      }
    },
    {
      "id": "3458764543361298337",
      "type": "sticky_note",
      "links": {
        "self": "https://api.miro.com/v2/boards/uXjVPybXf6M=/sticky_notes/3458764543361298337"
      },
      "parent": {
        "links": {
          "self": "https://api.miro.com/v2/boards/uXjVPybXf6M=/items/3458764543319467218"
        },
        "id": "3458764543319467218"
      },
      "createdAt": "2023-01-16T09:09:24Z",
      "createdBy": {
        "id": "3074457346407430089",
        "type": "user"
      },
      "data": {
        "content": "Risk10",
        "shape": "rectangle"
      },
      "geometry": {
        "width": 189,
        "height": 123.12
      },
      "modifiedAt": "2023-01-16T15:27:12Z",
      "modifiedBy": {
        "id": "3074457346407430089",
        "type": "user"
      },
      "position": {
        "x": 2313.614889226867,
        "y": 1130.742576946217,
        "origin": "center",
        "relativeTo": "parent_top_left"
      },
      "style": {
        "fillColor": "light_yellow",
        "textAlign": "center",
        "textAlignVertical": "middle"
      }
    }
  ],
  "links": {
    "self": "https://api.miro.com/v2/boards/uXjVPybXf6M=/sticky_notes?limit=10&cursor=",
    "next": "https://api.miro.com/v2/boards/uXjVPybXf6M=/sticky_notes?limit=10&cursor=MzQ1ODc2NDU0MzM2MTI5ODMzOH5zdGlja3lfbm90ZQ%3D%3D",
    "last": "https://api.miro.com/v2/boards/uXjVPybXf6M=/sticky_notes?limit=10&cursor=MzQ1ODc2NDU0MzM5ODI5NzA2N35zdGlja3lfbm90ZQ%3D%3D"
  },
  "cursor": "MzQ1ODc2NDU0MzM2MTI5ODMzOH5zdGlja3lfbm90ZQ==",
  "type": "cursor-list"
}

What I can't manage to read out the JSON file in variables is that I have the text and the ID.

If someone can help, that would be great.

Thanks a lot
Holger

Hey Holger,

I think this should be pretty simple for someone conversant with JavaScript and JSON, but that's not me...

@ComplexPoint?

If no one chimes in I have a few ideas about how to parse this.

-Chris

1 Like

You might have to fine-tune the match – to distinguish, for example between Risk1 and Risk10 – but broadly, using Keyboard Maestro %JSONValue% tokens, something like:

JSON search.kmmacros (16 KB)

2 Likes

Thank you very very much!
I will try, very happy.

For my understanding, I was able to address (I put the json in variable ajson), this works:

%JSONValue%ajson.data[0]%
%JSONValue%ajson.data[1]%

but I was not able to get it from the json path.
Thank you very much, I will try now

Holger

1 Like

It works great! Thanks!
Wonderful!

I am now able to expand the macro and change all the Sticky Notes in the Miroboard.
The best thing - I don't need to learn python or js to do that.

Thanks
Holger

2 Likes