JSON.parse() doesn't work in JS column?

I’m trying to get an array of values from an array of objects, looking like this:

[{"1":"a"; "2":"b"}, {"1":"c"; "2":"d"}, {"1":"e"; "2":"f"}]

My function looks like this:

var vals=[];
for(var i=0;i<testArray.length;i++){
   vals.push(testArray[i].val);
}

So my array is a string, got to a Text column from external API. And that’s why I decided to use JSON.parse() first in the JS column, but it doesn’t work.

Any advices from JS masters? Thank you in advance)

The JS column doesn’t accept arrays as parameters. If you’re passing a value that you want to be treated as an array, then the first part of your code needs to coerce it into an array using split or similar.

1 Like

Now that makes sense, thank you!
BTW I thought I could achieve this with Transform Array column. That’ll be even more simple I think.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.