如何使用jolt解析array of array
How to use jolt to parse array of array
我想用 jolt 来解析 json。但是我无法成功获得第一级的年龄值。有人可以帮助我吗?
输入json是这样的:
{
"name": "abc",
"age": "20",
"Photos": [
{
"a": "AAA.jpg",
"b": "BBB.jpg",
"XXX123": [
{
"v1": "AAA.jpg",
"v2": "BBB.jpg"
}
]
}
]
}
我的规格:
[
{
"operation": "shift",
"spec": {
"Photos": {
"*": {
"XXX123": {
"*": {
//"*": "&2.[&1].&",
"@(2,a)": "&2.[&1].a",
"@(2,b)": "&2.[&1].b",
"@(3,age)": "&3.[&1].age"
}
}
}
}
}
}
]
我想要的输出:
{
"XXX123" : [ {
"a" : "AAA.jpg",
"b" : "BBB.jpg",
"age" : "20"
} ]
}
规格
[
{
"operation": "shift",
"spec": {
"Photos": {
"*": {
"XXX123": {
"*": {
//"*": "&2.[&1].&",
"@(2,a)": "&2.[&1].a",
"@(2,b)": "&2.[&1].b",
"@(4,age)": "&2.[&1].age"
}
}
}
}
}
}
]
你很接近。
"@(3,age)": "&3.[&1].age"
needed
"@(4,age)": "&2.[&1].age"
From where that line was you needed to go up the tree 5 levels.
Counting from Zero
0 -> "*"
1 -> "XXX123"
2 -> "*"
3 -> "Photos"
4 -> your top level input
then lookup "age" in the top level map
我想用 jolt 来解析 json。但是我无法成功获得第一级的年龄值。有人可以帮助我吗? 输入json是这样的:
{
"name": "abc",
"age": "20",
"Photos": [
{
"a": "AAA.jpg",
"b": "BBB.jpg",
"XXX123": [
{
"v1": "AAA.jpg",
"v2": "BBB.jpg"
}
]
}
]
}
我的规格:
[
{
"operation": "shift",
"spec": {
"Photos": {
"*": {
"XXX123": {
"*": {
//"*": "&2.[&1].&",
"@(2,a)": "&2.[&1].a",
"@(2,b)": "&2.[&1].b",
"@(3,age)": "&3.[&1].age"
}
}
}
}
}
}
]
我想要的输出:
{
"XXX123" : [ {
"a" : "AAA.jpg",
"b" : "BBB.jpg",
"age" : "20"
} ]
}
规格
[
{
"operation": "shift",
"spec": {
"Photos": {
"*": {
"XXX123": {
"*": {
//"*": "&2.[&1].&",
"@(2,a)": "&2.[&1].a",
"@(2,b)": "&2.[&1].b",
"@(4,age)": "&2.[&1].age"
}
}
}
}
}
}
]
你很接近。
"@(3,age)": "&3.[&1].age"
needed
"@(4,age)": "&2.[&1].age"
From where that line was you needed to go up the tree 5 levels.
Counting from Zero
0 -> "*"
1 -> "XXX123"
2 -> "*"
3 -> "Photos"
4 -> your top level input
then lookup "age" in the top level map