cancel
Showing results for 
Search instead for 
Did you mean: 

Json Parse method

jose_guadamuz
New Contributor II

i can’t seem to get the json Parse method working when using a variable.

I am trying to get the following output

“customfield_11401”: [
{
“value”: “1223-CUST-A1”
}
]

I am trying to use the following expression but getting an error. Any help is appreciated.

JSON.parse(‘[{“value”: ‘+$dataCenterValue+’}]’)

3 REPLIES 3

Dheeraj
Employee
Employee

Try this …

image

tstack
Former Employee

I would advise against constructing strings to pass to a parser since it’s easy to get escaping wrong. As mentioned in another reply, you can use the target path in the Mapper to write the field. Or, you can use literal syntax directly to construct arrays/objects, like so:

[{
   "value": $dataCenterValue
}]

You can then use a mapper to write that to $customfield_11401.

jose_guadamuz
New Contributor II

Thanks @tstack @Dheeraj . Both ways worked great for me.