这是json输入:
{
"myRootKey" {
"directMove":"directValue",
"marker":"THE_MARKER",
"someTextField":"someString",
"someObject":{
"someKey":"value"
}
}
}
输出应该是:
{
"myRootKey" {
"subKey":{
"directMove":"directValue",
}
"THE_MARKER": {
"someTextField":"someString",
"someObject":{
"someKey":"value"
}
}
}
}
直接移动很明显,但marker
对象的输入值是多少?
答案 0 :(得分:0)
您可以匹配“someTextField”和“someObject”,但使用新的“@”/查找树逻辑来查找“标记”以用作输出路径。
规格
[
{
"operation": "shift",
"spec": {
"myRootKey": {
"directMove": "myRootKey.subKey.directValue",
"someTextField": "@(1,marker).someTextField",
"someObject": "@(1,marker).someObject"
}
}
}
]
答案 1 :(得分:0)
@(1,marker)
可让您检索标记字段的值&1
检索匹配节点的值所以您要查找的规格如下:
[
{
"operation": "shift",
"spec": {
"myRootKey": {
"directMove": "myRootKey.subKey.directValue",
"someTextField": "&1.@(1,marker).someTextField",
"someObject": "&1.@(1,marker).someObject"
}
}
}
]