2

Existing JSON:

{
 "name":"abc",
"place": "äbc"
}

I have a separte array as below:

    [documentDetails:{
    "name" : "doc1",
    "size" : "5"
    },
    documentDetails:{
    "name" : "doc1",
    "size" : "5"
    }
    ]

Final JSON REQUIRED:

 {
     "name":"abc",
    "place": "äbc",
documentDetails:{
    "name" : "doc1".
    "size" : "5"
    },
    documentDetails:{
    "name" : "doc1".
    "size" : "5"
    }
    }

How can I achieve the final json ?

HMT
  • 2,093
  • 1
  • 19
  • 51

1 Answers1

3

Try this:

%dw 2.0
output application/dw
var in1 = {
 "name":"abc",
"place": "äbc"
}

var in2 = [
    documentDetails:{
    "name" : "doc1",
    "size" : "5"
    },
    documentDetails:{
    "name" : "doc1",
    "size" : "5"
    }
]
---
{
    (in1),
    (in2)
}

Note that your "separate array" has typos. Fixed to the best of my understanding.

George
  • 2,758
  • 12
  • 16