I would like to check a condition and based on the type, would like to check another condition.
For BookingType:3, If TrackingList is available in the input, output should have a flag “TrackingAvailable” : “Y”. For all other bookingTypes we should not display this flag.
So far, I am able to check if TrackingList is available in the input and display the TrackingAvailable flag.
However I am unable to figure out how to add another condition for BookingType
Sample input, jolt spec and output are below. We need to update the joltspec to add BookingType condition as well such that TrackingAvailable is displayed only for BookingType:3
Input
{
"Booking": [
{
"BookingLines": {
"BookingLine": [
{
"Metadata": {
"TrackingList": {
"Tracking": [
{
"TrackingNumber": "1232131231"
}
]
}
}
}
]
},
"BookingType": "1"
}
]
}
Jolt Spec
[
{
"operation": "modify-default-beta",
"spec": {
"Booking": {
"*": {
"*": "Booking[&1].&",
"BookingLines": {
"BookingLine": {
"*": {
"Metadata": {
"TrackingList": {
"Tracking": "null"
}
}
}
}
}
}
}
}
},
{
"operation": "shift",
"spec": {
"Booking": {
"*": {
"BookingLines": {
"BookingLine": "Booking[&2].BookingLines.BookingLine"
}
}
}
}
}
,
{
"operation": "shift",
"spec": {
"Booking": {
"*": {
"*": "Booking[&1].&",
"BookingLines": {
"BookingLine": {
"*": {
"Metadata": {
"TrackingList": {
"Tracking": {
"null": {
"#N": "Booking[&8].BookingLines.BookingLine[&5].Metadata.TrackingAvailable"
},
"*": {
"#Y": "Booking[&8].BookingLines.BookingLine[&5].Metadata.TrackingAvailable"
}
}
}
}
}
}
}
}
}
}
}
]
output
{
"Booking": [
{
"BookingLines": {
"BookingLine": [
{
"Metadata": {
"TrackingAvailable": "Y"
}
}
]
}
}
]
}
Vikas Gonti is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.