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 ?

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I didn't use the round brackets . Thanks for the help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.