I've the following JSON:-
{
"ROWNUM": "328938",
"SOURCE_NAME": "I2323",
"ID": "333333",
"FIRST_NAME": "A121221",
"KNOWN_AS": "G1223321",
"LAST_NAME": "sadsadsd",
"PLACE_OF_BIRTH": "Indsadsadsaddsaia",
"DATE_OF_BIRTH": "sadsaddsa",
"UPRN": "sadsadsad",
"POST_CODE": "asdsadsda",
"POST_TOWN": "GLASGOW",
"ESTIMATED_DOB": "N",
"LAST_UPDATED": "2019-02-11T13:57:05.264Z",
"cluster_id": 3020,
"aliases": [
{
"_id": {
"timestamp": 1550152767,
"machineIdentifier": 6505561,
"processIdentifier": 59,
"counter": 2775622,
"time": 1550152767000,
"timeSecond": 1550152767,
"date": 1550152767000
},
"ROWNUM": "328938",
"SOURCE_NAME": "I2323",
"ID": "333333",
"FIRST_NAME": "A121221",
"KNOWN_AS": "G1223321",
"LAST_NAME": "sadsadsd",
"PLACE_OF_BIRTH": "Indsadsadsaddsaia",
"DATE_OF_BIRTH": "sadsaddsa",
"UPRN": "sadsadsad",
"POST_CODE": "asdsadsda",
"POST_TOWN": "GLASGOW",
"ESTIMATED_DOB": "N",
"LAST_UPDATED": "2019-02-11T13:57:05.264Z",
"cluster_id": 3020,
"score": "0.9997580647468567"
},
{
"_id": {
"timestamp": 1550152767,
"machineIdentifier": 6505561,
"processIdentifier": 59,
"counter": 2775622,
"time": 1550152767000,
"timeSecond": 1550152767,
"date": 1550152767000
},
"ROWNUM": "328938",
"SOURCE_NAME": "I2323",
"ID": "333333",
"FIRST_NAME": "A121221",
"KNOWN_AS": "G1223321",
"LAST_NAME": "sadsadsd",
"PLACE_OF_BIRTH": "Whatever",
"DATE_OF_BIRTH": "sadsaddsa",
"UPRN": "sadsadsad",
"POST_CODE": "asdsadsda",
"POST_TOWN": "PAISLEY",
"ESTIMATED_DOB": "N",
"LAST_UPDATED": "2019-02-11T13:57:05.264Z",
"cluster_id": 3020,
"score": "0.9997580647468567"
}
]
}
Is there a jolt spec that would lowercase every key, including keys in nested objects? (in this case what is under aliases
).
The following works for the top level keys but not for the nested ones:
[
{
// unwrap the keys and values into literal
// "key" : "A", "value" : "b"
"operation": "shift",
"spec": {
"*": {
"$": "&1.key",
"@": "&1.value"
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"*": {
// Now that the origional key
// is on the "right hand side"
// lowercase it
"key": "=toLower"
}
}
},
{
// pivot back, the now lowercased keys
"operation": "shift",
"spec": {
"*": {
"value": "@(1,key)"
}
}
}
]
Thanks!