Hello,
I have problems with the mapping of JSON ArrayList with dynamic number of Items. That means, first call I have i.e. 2 Items. Next call 5 Items.
Here first example of JSON Source:
{
"email": "first.last@company.com",
"costs": 12.34,
"attachments": [
{
"id": "d9274e6a-f880-4a07-a356-50e65af711b5",
"fileName": "text1.txt"
},
{
"id": "142efeff-6cf1-461e-b210-e0601539be23",
"fileName": "pdf1.pdf"
},
{
"id": "e85e354a-dd66-43e0-9f07-0fa3d9f592f9",
"fileName": "image1.PNG"
}
]
}
Here second example of JSON Source:
{
"email": "name.lastname@company.com",
"costs": 43.21,
"attachments": [
{
"id": "142efeff-8888-461e-b210-e0601539be23",
"fileName": "file1.xls"
},
{
"id": "e85e354a-7777-43e0-9f07-0fa3d9f592f9",
"fileName": "image2.PNG"
}
]
}
Both should be transformed and mapped to the target JSON structure, which here is a sample for
Target 1
{
"Ticket": {
"Customer": "first last"
},
"Attachment": [
{
"Filename": "text1.txt"
},
{
"Filename": "pdf1.pdf"
},
{
"Filename": "image1.PNG"
}
]
}
and here a sample for the seond target:
{
"Ticket": {
"Customer": "name lastname"
},
"Attachment": [
{
"Filename": "file1.xls"
},
{
"Filename": "image2.PNG"
}
]
}
I don't know how to manage this with one DataMapper with JSON Input and JSON Output.
A simple mapping from "fileName" -> "Filename" will result in this:
/*Created by Liquid Data Mapper Libraries (url) for UNLICENSED TRIAL VERSION FOR EVALUATION USE ONLY*/
{
"Ticket": {
"CustomerUser": "first last"
},
"Attachment": [
{
"Filename": "text1.txt pdf1.pdf image1.PNG"
}
]
}
Can somebody help me and give some advise?
Thanks very much
Oliver