I have a Text which is invoking changes in the board. If there’s only one change, I extract a simple JSON object. If there are multiple changes, I extract an array of simple JSON objects.
I use FormulaMap(CurrentValue.ParseJSON(“$.MyKey”)) to extract the value of each key.
The problem is it only reads the values when I have only one simple JSON object, when I have an array of objects it doesn’t work.
I think the problem is that coda does not now that is an array of objects.
If you are trying to do a FormulaMap or Foreach using a string with “[ ]” delimiters, the coda formula consider one element and the parseJSON formula also does not expect an array.
To make it work, you need to convert the string into an array and then use formulaMap and parseJSON. I think you cannot do it easily with built in formulas.
I made a simple pack that do this for you. It just parse the input string and return an array of objects (link to the pack). It uses the JSON.parse() javascript function.
With this you can use something like:
str2array(‘[{“id”: 123, “name”: “TEST”},{“id”: 456, “name”: “TEST2”}]’).ForEach(
currentValue.parseJSON(“$.name”)
)
This will return a list equal to (“TEST”, “TEST2”)