Repeating a varying number of unique values into a JSON output file - how!?

Hey all,

I have this JSON I need to output:

{
  "query": {
    "ids": {
      "values": [
        "1",
        "4",
        "100"
      ]
    }
  }
}

In my Server Action I’m querying a table, that returns a number of unique ID’s. The number of unique ID’s will differ, it’s not a fixed number (or this would be easy!).

What I need to do, is include those unique ID’s into the “values”: section. But as the number of records differs, i’m not sure how to do this dynamically.

I’ve tried using a repeat on the query, to ouput jut the unique ID’s. I’ve then tried a set value step to perhaps try to construct the section of JSON and then include that - but I keep getting stuck on the issue of the number of unique ID’s being dynamic.

Love some help here if anyone can recommend how to do this with Wappler.

Community Page
Last updated: