Options
- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
How to rename array key names in NiFi?
Labels:
- Labels:
-
Apache NiFi
New Contributor
Created ‎10-21-2022 10:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I need a little help, I want to rename all keys in the array "orderItems"
Input:
{
"id": 105,
"referrerId": 0,
"typeId": 1,
"orderItems": [
{
"id": 115,
"typeId": 6,
"itemVariationId": 0,
"quantity": 1,
"attributeValues": null,
"vatField": 0,
"amounts": [
{
"currency": "EUR",
"priceGross": 5.99,
"priceNet": 5.0336,
"discount": 0
}
]
},
{
"id": 116,
"typeId": 2,
"itemVariationId": 1088,
"quantity": 1,
"attributeValues": "5",
"vatField": 0,
"amounts": [
{
"currency": "EUR",
"priceGross": 29.9,
"priceNet": 25.1261,
"discount": 0
}
]
}
],
"addressRelations": [
{
"id": 10,
"orderId": 105,
"typeId": 1,
"addressId": 7
},
{
"id": 11,
"orderId": 105,
"typeId": 2,
"addressId": 7
}
]
}
Excepted Output:
{
"id": 105,
"referrerId": 0,
"plentyId": 61757,
"typeId": 1,
"orderItems": [
{
"text01": 115,
"text02": 6,
"text03": 0,
"text04": 1,
"text05": null,
"text06": 0,
"amounts": [
{
"currency": "EUR",
"priceGross": 5.99,
"priceNet": 5.0336,
"discount": 0
}
]
},
{
"text01": 116,
"text02": 2,
"text03": 1088,
"text04": 1,
"text05": "5",
"text06": 0,
"amounts": [
{
"currency": "EUR",
"priceGross": 29.9,
"priceNet": 25.1261,
"discount": 0
}
]
}
],
"addressRelations": [
{
"id": 10,
"orderId": 105,
"typeId": 1,
"addressId": 7
},
{
"id": 11,
"orderId": 105,
"typeId": 2,
"addressId": 7
}
]
}
I have tried some JOLT-Specs, but nothing worked.
Hope, somebody can help me 🙂
Thanks!
1 REPLY 1
Expert Contributor
Created ‎10-26-2022 08:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
can you try it with:
[ { "operation": "shift", "spec": { "orderItems": { "*": { "id": "orderItems[&1].text01", "typeId": "orderItems[&1].text02", "itemVariationId": "orderItems[&1].text03", "quantity": "orderItems[&1].text04", "attributeValues": "orderItems[&1].text05", "vatField": "orderItems[&1].text06", "amounts": "orderItems[&1].amounts" } }, "*": "&" } } ]
Let me know if there needs something to change.
Greetings
