Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
JSON Payload:
{
"customer-request": {
"customer": {
"ExternalId": "ab100",
"CustomerType": "Individual",
"FullName": "John Smith",
"customerProducts": [
{
"ProductName": "Laptop",
"Quantity": 1
}
],
"customerProducts": [
{
"ProductName": "Mouse",
"Quantity": 1
}
],
"customerActivities": [
{
"CustomerType": "Gold",
"CustomerSource": "Web"
}
]
}
}
}
Required OutPut:
Talend Job is as follows:
As you can see, if the JSON doesn't contain data for "customerActivities": []; then there is no data that is being passed from second tExtractJSONFields_2.
How can we write a code in tJavaRow component that can check for "customerActivities": []; but still pass the rest of the fields to the output? or is there some other way ?
Thank you
any help?
@Jennifer Siders ,It seems like it is an invalid Json sting for data extraction, there exists duplicate key 'customerProducts', you can't extract all data from duplicate key.
I don't think so...anyhow..we can assume it as CustomerType1, but the issue exists right?
My tJavaRow contains the following:
output_row.ExternalId = input_row.ExternalId;
output_row.CustomerType = input_row.CustomerType;
output_row.FullName = input_row.FullName;
output_row.CustomerActivities = input_row.CustomerActivities;
output_row.ProductName = input_row.ProductName;
output_row.Quantity = input_row.Quantity;
Now in some of the payloads the CustomerActivities[] can be empty and i need to hand this, so that next tExtractJSON can get the entire data.