cancel
Showing results for 
Search instead for 
Did you mean: 

Convert array with objects into object with key/value pairs

DirkZ70
New Contributor

Hello all,
i try to convert the following input/source into the described target structure with a mapper snap but i am not able to find a solution for this. Can anybody give me a hint or example how i can solve this problem 

My current source:

[
  {
    "recordset": {
      "item_id": "test_1",
      "classification": {
        "@class_id": "AB123",
        "attributes": [
          {
            "@name": "key_1",
            "$": "value_1"
          },
          {
            "@name": "key_2",
            "$": "value_2"
          },
          {
            "@name": "key_3",
            "$": "value_3"
          }
        ]
      }
    }
  },
  {
    "recordset": {
      "item_id": "test_2",
      "classification": {
        "@class_id": "AB456",
        "attributes": [
          {
            "@name": "key_4",
            "$": "value_4"
          },
          {
            "@name": "key_5",
            "$": "value_5"
          },
          {
            "@name": "key_6",
            "$": "value_6"
          },
          {
            "@name": "key_7",
            "$": "value_7"
          }
        ]
      }
    }
  }
]

The target which i expect should look like the following:

[
  {
    "recordset": {
      "item": "test_1",
      "classification": {
        "class_id": "AB123",
        "attributes": {
          "key_1": "value_1",
          "key_2": "value_2",
          "key_3": "value_3"
        }
      }
    }
  },
  {
    "recordset": {
      "item": "test_2",
      "classification": {
        "class_id": "AB456",
        "attributes": {
          "key_4": "value_4",
          "key_5": "value_5",
          "key_6": "value_6",
          "key_7": "value_7"
        }
      }
    }
  }
]

Many thanks in advance,

Dirk

 

 

1 ACCEPTED SOLUTION

ptaylor
Employee
Employee

Attached is a pipeline to do this mapping. It looks like this:

ptaylor_1-1727275237154.png

First Mapper:

ptaylor_0-1727275209809.png

Second Mapper:

ptaylor_2-1727275418562.png

Hope that helps!

 

 

View solution in original post

2 REPLIES 2

ptaylor
Employee
Employee

Attached is a pipeline to do this mapping. It looks like this:

ptaylor_1-1727275237154.png

First Mapper:

ptaylor_0-1727275209809.png

Second Mapper:

ptaylor_2-1727275418562.png

Hope that helps!

 

 

DirkZ70
New Contributor

Perfect,
you are a genius 👍
Your example do exactly what i needed.

Many thanks,
Dirk