I am using the Flatten Json processor with delimiter _ , this works fine in so far that it does flatten nested records. But I also noticed that it interferes with keys which already have "_" in them. For eg:
{
"first_name": "myfirstname",
"last_name": "mylastname",
"address": {
"billing": "mybilling",
"shipping": "myshipping"
}
}
flattened to:
{
"[\"first_name\"]": "myfirstname",
"[\"last_name\"]": "mylastname",
"address_billing": "mybilling",
"address_shipping": "myshipping"
}
while, 'address' record is flattened as expected, the keys first_name and last_name which have an _ character are also disturbed. Is there a way I can circumvent this? (perhaps a way to escape non record types?)
To workaround this issue you can use either
JoltTransformJson processor
(or)
Keep the seperator(like '|','-'..etc) in FlattenJson which is
not present in key names.
1. Using JoltTransformJson Processor:
Spec:
[
{
"operation": "shift",
"spec": {
"*": "&",
"address": {
"*": "address_&"
}
}
}
]
Output:
{
"first_name" : "myfirstname",
"last_name" : "mylastname",
"address_billing" : "mybilling",
"address_shipping" : "myshipping"
}
2.FlattenJson Processor:

Output:
{
"first_name": "myfirstname",
"last_name": "mylastname",
"address|billing": "mybilling",
"address|shipping": "myshipping"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With