Here is my xml, in that first I need to check 'RecordsEntries' should not be 'null', then RecordEntry shouldn't be null
followed by mapping code
<?xml version="1.0" encoding="UTF-8"?>
<Records>
<storenumber />
<calculated>false</calculated>
<subTotal>12</subTotal>
<RecordsEntries>
<RecordEntry>
<deliverycharge>30.0</deliverycharge>
<entryNumber>8</entryNumber>
<Value>true</Value>
</RecordEntry>
<RecordEntry>
<deliverycharge>20.0</deliverycharge>
<entryNumber>7</entryNumber>
<Value>false</Value>
</RecordEntry>
</RecordsEntries>
<RecordsEntries>
<RecordEntry>
<deliverycharge>30.0</deliverycharge>
<entryNumber>8</entryNumber>
<Value>false</Value>
</RecordEntry>
</RecordsEntries>
</Records>
Tried multiple scenario's also used when
condition checking but somewhere missing parenthesis or correct format
orders: {
order: {
StoreID: payload.Records.storenumber,
Total: payload.Records.calculated,
(( payload.Records.RecordsEntries.*RecordEntry ) map {
IndividualEntry: {
Number:$.entryNumber,
DeliverCharge:$.deliverycharge
}
} when ( payload.Records.RecordsEntries != null and payload.Records.RecordsEntries.*RecordEntry !=null))}
}
getting error like missing )
. Tried other way around by checking the null condition directly inside the first loop got error like "Cannot coerce array to an boolean". Please suggest. Thanks.