Help with generating my first JSON

Hi,
I have to generate my first json for another system and I'm stuck with the implementation - maybe one of you can help me out. :slight_smile:

the sample data is like this:
sample-data.xlsx (8.9 KB)
sample-data2.xlsx (9.0 KB)

and the output should be like this:
(the featureNames are not fixed - other products can have other or also none features)

[
  {
    "parentId": "p70451",
    "parentName": "Kappe 55-62 cm ELYSEE",
    "childId": 199336,
    "childName": "Kappe Roman 53-61cm orange ELYSEE",
    "attributes": {
      "Farbe": "orange",
      "Größe": "55-62 cm",
      "Material": "80% Polyester / 20% Baumwolle"
    }
  },
  {
    "parentId": "p70451",
    "parentName": "Kappe 55-62 cm ELYSEE",
    "childId": 199337,
    "childName": "Kappe Daniel 53-61cm gelb ELYSEE",
    "attributes": {
      "Farbe": "gelb",
      "Größe": "55-62 cm",
      "Material": "80% Polyester / 20% Baumwolle"
    }
  }
]

I have tried many things - my best result was, that in the attribute section I have something like that.

    "attributes": {
      "featureName": "Farbe",
      "featureValue": "orange",
      "featureName": "Größe",
      "featureValue": "55-62 cm"
    }

and that is not what I need.

I hofe someone can help me - thanks in advance!

best wishes
Peter

I would do it like this:
json.morph (5.6 KB)

Best regards,

Jochen

2 Likes

Thank you so much @Jochen_Marquardt
the pivot of the features was the missing brick in my thoughts - you made my day!

have a great day!
Peter

1 Like

One thing worth noting is that the Construct JSON action always identifies if there is JSON structures in any of the fields and builds them into nested JSON elements. This is happening in @Jochen_Marquardt example for a single layer but it will handle nesting for any number of levels deep. Thus you can create incredibly complex nested JSON data structures using this method.

2 Likes