Merging segments in json

Hi there, I have input of a snap coming in as

but want to have it as and “order-line” renamed as “order-lines

Basically grouping the “data” segment.

I have tried Join, Group by Field, Mapper snaps but nothing worked. surely I am not doing right.

Any pointers on how to achieve it?

Thanks
Manohar
jsoninput.json (106.8 KB)

Hi @manohar ,

How I see it when I use the json file, There are two same ‘data’ objects. One with only orderline and one with the other objects inside so that means that some ‘data’ objects contain the orderline and some does not.

When i try to extend the ‘data’ object with the orderline and rename it. Only the second data object gets the new orderlines object because that ‘data’ object only contains the Order-line the other Data object just gets a ‘null’ value in the orderlines object field.

I don’t know where you get your data from but it seems that not every data object has the order-line.

pipeline below for more explanation
community_pipeline_V1.0_2022_11_10.slp (124.9 KB)

Hi @JensDeveloper appreciate your help.

In fact, the orderline is not coming in the ‘data’ object. I just transformed it as below to have it part of the data thinking it might help, like using join as below

‘data’ with out orderlines is coming from different snap and orderlines are coming from different snap

please find attached the input jsons and the json that I am trying to achive as final.

Thank you for you help,
Manohar
input_json2_with_orderlines.json (82.4 KB)
input_json1_with_outorderlines.json (23.2 KB)
Final_Expected_Json_structure.json (2.4 KB)

Hey @manohar,

Try the following pipeline. Keep in mind that this will work if you only have these 2 incoming objects.

Structuring Data_2022_11_10.slp (126.1 KB)

1 Like

Hi @bojanvelevski , your solution works like charm…

there’s one issue though. After the Structure Snap, I get Order lines in its original format, as in the right box in below screenshot. but I need the output shown in the left box.

Example -

In
“id”: {
@type”: “integer”,
“$”: “40114”
},
needs to be transformed to as
“id”: “40114”,

Alos, don’t need some of the nodes like “accounting-total”, “created-at”.

Then there are some like which needs to be mapped as it is

“line-num”: “00010”, to “line-num”: “00010”,

I have tried using another structure, and mapper snaps and they come out as below

Any direction in this case?

Thanks
Manohar

You need a lot of transformations there, so I would suggest using additional Mapper with a mapping root that goes down to order-lines and manually map the output. Here, I updated the pipeline and did some of the output fields:

Structuring Data_2022_11_11.slp (127.8 KB)

4 Likes

Thank you very much @bojanvelevski. That’s something new I learned today the capability of Mapper snap without using code.

1 Like