Stored Transformation
Stored transformation detail
Inspect version history, edit inputs, and save a new version without overwriting prior records.
def v($k): .[$k].value // null; def parsed_address: (v("address") // "") as $a | ($a | capture("^(?<streetAddress>.*?)[.,]\\s*(?<postalCode>\\d{5})\\s+(?<municipality>[^.]+)")) as $m | {streetAddress: ($m.streetAddress | gsub("\\s+$"; "")), postalCode: $m.postalCode, municipality: ($m.municipality | gsub("\\s+$"; "") | gsub("\\.$"; "")), province: (if ($m.postalCode | startswith("28")) then "Madrid" else null end), autonomousCommunity: (if ($m.postalCode | startswith("28")) then "Comunidad de Madrid" else null end), country: "España"} | with_entries(select(.value != null)); {object: ({name: {value: "Hotel PID", lang: "es"}} + (if v("description") != null then {hasDescription: {object: {shortDescription: {value: v("description"), lang: "es"}}}} else {} end) + (if v("address") != null then {hasLocation: {object: parsed_address}} else {} end))}
{
"object": {
"hasDescription": {
"object": {
"shortDescription": {
"lang": "es",
"value": "Aparthotel TH Las Rozas"
}
}
},
"hasLocation": {
"object": {
"autonomousCommunity": "Comunidad de Madrid",
"country": "Espa\u00f1a",
"municipality": "Las Rozas",
"postalCode": "28230",
"province": "Madrid",
"streetAddress": "Camino Viejo de Madrid, 38"
}
},
"name": {
"lang": "es",
"value": "Hotel PID"
}
}
}