cancel
Showing results for 
Search instead for 
Did you mean: 

JSON Formatting - Mapping Key and Value

sobha353
New Contributor

I have a pipeline which reads data from source in JSON format and below is the format of json data retrieved. I am looking to map the values and not getting the desired result since the data is in string. Can anyone help on this please. Kindly advise.

"dataDetails": {
"data": "{"data":[{"First Name":"testfirstname1","Last Name":"testsecondname1","Status":"Active"},{"First Name":"testfirstname2","Last Name":"testsecondname2","Status":"Active"},{"First Name":"testfirstname3","Last Name":"testsecondname3","Status":"Active"}]}"

Mapper Expression used for mapping one of the above fields after Rest Get snap:
$data.mapValues((val, key) => (key == 'Status') ? val : ' '

1 ACCEPTED SOLUTION

ivicakoteski
New Contributor III

Hi @sobha353 ,

You can parse the string as JSON using the JSON.parse() function in the mapper snap.

 

JSON.parse($dataDetails.data)

 

ivicakoteski_1-1709797192664.png

Hence, you can easily map the data as desired.
Hope this helps!

BR.
Ivica

View solution in original post

2 REPLIES 2

ivicakoteski
New Contributor III

Hi @sobha353 ,

You can parse the string as JSON using the JSON.parse() function in the mapper snap.

 

JSON.parse($dataDetails.data)

 

ivicakoteski_1-1709797192664.png

Hence, you can easily map the data as desired.
Hope this helps!

BR.
Ivica

Thank you @ivicakoteski 
This worked perfectly and I am getting the desired result