Jolt 变换 json 数组
Jolt transform json array
我需要 Jolt 转换方面的帮助。
我有一个数组,它由许多 json 个对象组成。 (https://jolt-demo.appspot.com/ )
[
{
"table_name": "table_vd",
"scratch_name": "l1_sample_1_1",
"scratch_order": 1
},
{
"table_name": "table_vd",
"scratch_name": "l1_sample_1_1",
"scratch_order": 34
},
{
"table_name": "table_vd",
"scratch_name": "l1_sample_2",
"scratch_order": 3
}
]
需要对 Jolt 进行什么转换才能得到以下结果?
{
"table_name" : "table_vd",
"data" : [ {
"scratch_name" : "l1_sample_1_1",
"scratch_order" : 1
}, {
"scratch_name" : "l1_sample_1_1",
"scratch_order" : 34
}, {
"scratch_name" : "l1_sample_2",
"scratch_order" : 3
} ]
}
现在我有下一个 Jolt 结构:
[
{
"operation": "shift",
"spec": {
"*": {
"table_name": "table_name",
"*": {
"@0": "data[0].&1"
}
}
}
}
]
但是下面的结果不正确:
{
"table_name" : [ "table_vd", "table_vd", "table_vd" ],
"data" : [ {
"scratch_name" : [ "l1_sample_1_1", "l1_sample_1_1", "l1_sample_2" ],
"scratch_order" : [ 1, 34, 3 ]
} ]
}
您通过分离 "table_name"
和其他 ("*"
) 使用条件逻辑开始得很好。将“*”(其余的)重新排列为"*": "data[&1].&"
,然后通过[选择"table_name"
数组值的第一个元素基数 规格如
[
{
"operation": "shift",
"spec": {
"*": {
"table_name": "&",
"*": "data[&1].&"
}
}
},
{
"operation": "cardinality",
"spec": {
"table_name": "ONE"
}
}
]
我需要 Jolt 转换方面的帮助。 我有一个数组,它由许多 json 个对象组成。 (https://jolt-demo.appspot.com/ )
[
{
"table_name": "table_vd",
"scratch_name": "l1_sample_1_1",
"scratch_order": 1
},
{
"table_name": "table_vd",
"scratch_name": "l1_sample_1_1",
"scratch_order": 34
},
{
"table_name": "table_vd",
"scratch_name": "l1_sample_2",
"scratch_order": 3
}
]
需要对 Jolt 进行什么转换才能得到以下结果?
{
"table_name" : "table_vd",
"data" : [ {
"scratch_name" : "l1_sample_1_1",
"scratch_order" : 1
}, {
"scratch_name" : "l1_sample_1_1",
"scratch_order" : 34
}, {
"scratch_name" : "l1_sample_2",
"scratch_order" : 3
} ]
}
现在我有下一个 Jolt 结构:
[
{
"operation": "shift",
"spec": {
"*": {
"table_name": "table_name",
"*": {
"@0": "data[0].&1"
}
}
}
}
]
但是下面的结果不正确:
{
"table_name" : [ "table_vd", "table_vd", "table_vd" ],
"data" : [ {
"scratch_name" : [ "l1_sample_1_1", "l1_sample_1_1", "l1_sample_2" ],
"scratch_order" : [ 1, 34, 3 ]
} ]
}
您通过分离 "table_name"
和其他 ("*"
) 使用条件逻辑开始得很好。将“*”(其余的)重新排列为"*": "data[&1].&"
,然后通过[选择"table_name"
数组值的第一个元素基数 规格如
[
{
"operation": "shift",
"spec": {
"*": {
"table_name": "&",
"*": "data[&1].&"
}
}
},
{
"operation": "cardinality",
"spec": {
"table_name": "ONE"
}
}
]