Parsing a JSON array into a "Multiple Select" field through the curl API

Topic Labels: API
2082 1
Showing results for 
Search instead for 
Did you mean: 
4 - Data Explorer
4 - Data Explorer

I’m trying to create a record using the curl API, and one of the fields in my record is of type “Multiple Select”. The possible values are integers (formatted as strings since that’s the only option for this field), so it’s supposed to be entered as [“1”,“2”,“3”] etc. However, I am using an integration that only supports mustache formatting, and with mustache, JSON arrays get parsed as [1,2,3] and this is not accepted by the API. I’ve tried setting “typecast”:true and it doesn’t work.

Is there another way of accomplishing what I’m trying to do here?

1 Reply 1

On a limb here, these issues always confuse me. Does this help?

var json = '{"prop":{"options":[1,2,3]}}'; // string
var obj  = JSON.parse(json);               // parsed
var data = {options: obj.prop['options'].map(function(x){ return {name: '"' + x + '"'}; })};

Which returns this -

{options=[{name="1"}, {name="2"}, {name="3"}]}