deepanshu_1
4 years agoNew Contributor III
Order sort
Dear All,
I am implementing a pipeline but I am taking more than enough snaps, my output is:
Desired output:
Is this possible using a single mapper snap?
Thanks in advance.
Dear Aleksandar,
Thanks for the reply but I am facing issue below:
BR,
Deepanshu
Hi @deepanshu.1 ,
Can you please attach the output of the REST API (I suppose it is in JSON format) ?
Cheers,
Marjan
Hi Marjan,
Below is the output:
[
{
“group”:[
{
“location”:
“Konstanz”
“temp”:
269.63
“pressure”:
1028
“humidity”:
82
}
{
“location”:
“India”
“temp”:
305.49
“pressure”:
1013
“humidity”:
15
}
{
“location”:
“Novinki”
“temp”:
265.38
“pressure”:
1035
“humidity”:
87
}
{
“location”:
“Ptitsefabrika”
“temp”:
283.25
“pressure”:
1018
“humidity”:
80
}
]
}
]
Regards,
Deepanshu
Hi @deepanshu.1 ,
Please try with the following in the mapper and let me know if it helps you:
$.group.map((x,index)=> {“Location”:x.location, “Temp”:x.temp -273.15, “Temp_Order”:jsonPath($, “group[].temp").sort((a,b)=>a-b).indexOf(x.temp)+1, “Press”:x.pressure, “Press_Order”:jsonPath($, "group[].pressure”).sort((a,b)=>a-b).indexOf(x.pressure)+1, “Humidity”:x.humidity, “Humidity_Order”:jsonPath($, “group[*].humidity”).sort((a,b)=>a-b).indexOf(x.humidity)+1})
BR,
Marjan
Dear Marjan,
I am getting the below error:
Could not compile expression: $.group.map((x,index)=> {“Loca … (Reason: Invalid token: ‘“’ for expression: $.group.map((x,index)=> {“Loca …; Resolution: Please check expression syntax)
Br,
Deepanshu