cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Order sort

deepanshu_1
New Contributor III

Dear All,

I am implementing a pipeline but I am taking more than enough snaps, my output is:

image

Desired output:

image

Is this possible using a single mapper snap?

Thanks in advance.

10 REPLIES 10

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)

image

Br,
Deepanshu

Hi @deepanshu.1 ,

Please replace quotation marks โ€œ and โ€ with " in the expression in mapper.

BR,
Marjan

It should look like this:

image

I donโ€™t know why the editor is replacing the symbol * and the quotation marks.

BR,
Marjan

AleksandarAngel
Contributor III

Hi @deepanshu.1,

Also you can try to insert the asterisk symbol โ€˜*โ€™ in between the marked square bracket on the picture below:
community

BR,
Aleksandar