2017-08-02 67 views
0

我有一个JSON输入,我使用JOLT转换进行转换。我的问题是我想使用输入键的值作为输出数据中的新键,并且将另一个值添加到该新输出的键中。这是我输入:Jolt使用两个2值创建一个新的键/值对

"Description": { 
    "Name": "John", 
    "KeyNameId": "John123", 
    "Description": "John's description" 
} 

而且我想我的输出是:

"Description": { 
    "John123": "John's description" 
} 

无论如何要做到这一点,而不使用两个移位操作? 或者如果不可能的话,两班倒?

回答

1

是的,它可以使用“@(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)" 
     } 
    } 
    } 
] 
相关问题