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.