I'm trying to selectively update some values in a nested hierarchical data structure.
I have nested input data such as
var flights =
{
"flights": {
"flight": {
"airline-name": "american",
"flight-code": "AA103",
"plane-type": null,
"longitude": "33.94250107",
"price": "+750.00",
"destination": {
"airport-name": "los angeles international airport",
"city": "los angeles",
"altitude": "125",
"longitude":"33.94250107"
}
},
"flight": {
"available-seats": "+18.00",
"longitude": "33.94250107",
"airline-name": "delta",
"plane-type": "boeing 747",
"destination": {
"airport-name": "los angeles international airport",
"longitude": "33.94250107"
}
}
}
}
I want to mask all the longitudes at all levels with one case statement.
flights dw::util::Values::update {
case dest at .flights.*flight.*destination.longitude -> "******"
case ptype at .flights.*flight.*"plane-type" if((ptype ~= null)) -> "*******"
}
only matches inside the destination value.
{
"flights": {
"flight": {
"airline-name": "american",
"flight-code": "AA103",
"plane-type": "*******",
"longitude": "33.94250107",
"price": "+750.00",
"destination": {
"airport-name": "los angeles international airport",
"city": "los angeles",
"altitude": "125",
"longitude": "******"
}
},
"flight": {
"available-seats": "+18.00",
"longitude": "33.94250107",
"airline-name": "delta",
"plane-type": "boeing 747",
"destination": {
"airport-name": "los angeles international airport",
"longitude": "******"
}
}
}
}
Also, is there a way to do something like flights..*destination instead of hardcoding the path?