![](/img/trans.png)
[英]Create “key - value” pair json from the list of given json values using JOLT
[英]Jolt Transform using two 2 values to create a new key/value pair
我有一個使用JOLT shift轉換的JSON輸入。 我的問題是我想使用輸入鍵的值作為輸出數據中的新鍵,並並行將另一個值添加到該新的輸出鍵中。 這是我的輸入:
"Description": {
"Name": "John",
"KeyNameId": "John123",
"Description": "John's description"
}
我希望我的輸出是:
"Description": {
"John123": "John's description"
}
無論如何要執行此操作而不使用兩個移位操作? 還是如果無法進行兩次輪班?
是的,可以使用“ @(Number,words)”運算符進行一次轉換。
輸入-為清楚起見略作修改
{
"Top": {
"Name": "John",
"KeyNameId": "John123",
"Description": "John's description"
}
}
規格
[
{
"operation": "shift",
"spec": {
"Top": {
// match the key "Description" and copy it's value to the Output.
// The Output path being defined by @(1,KeyNameId), which means
// go back up the tree 2 levels (0,1) and lookup the value of
// "KeyNameId"
"Description": "@(1,KeyNameId)"
}
}
}
]
更准確地說,
[
{
"operation": "shift",
"spec": {
"Description": {
"@Description": "Description.@KeyNameId"
}
}
}
]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.