使用 JOLT 创建一个新数组
create a new array using JOLT
我正在尝试使用 JOLT 修改 JSON 输出,直到现在我主要将它用于 rename/remove 字段。
我想创建一个现有 2 个数组的新对象作为元素。
input.json
[
{
"features": [
{
"featureId": 1,
"feature": "feature"
}
],
"product": [
{
"id": 1,
"name": "name"
}
]
}
]
当前规格 json:
[{
"operation": "shift",
"spec": {
"*": {
"features": {
"*": {
"featureId": "[&3].&2.[&1].featureId",
"feature": "[&3].&2.[&1].feature"
}
},
"product": {
"*": {
"id": "[&3].&2.[&1].id",
"name": "[&3].&2.[&1].name"
}
}
}
}
}
]
预期输出:
[
{
"newarray": {
"features": [
{
"featureId": 1,
"feature": "feature"
}
],
"product": [
{
"id": 1,
"name": "name"
}
]
}
}
]
基本上,我想将我现有的两个数组移动到一个新对象中。提前致谢!
规格
[
{
"operation": "shift",
"spec": {
"*": { // outer array index
// match features and product which are lists
// and copy those lists to the output
"*": "[0].newarray.&"
}
}
}
]
我正在尝试使用 JOLT 修改 JSON 输出,直到现在我主要将它用于 rename/remove 字段。
我想创建一个现有 2 个数组的新对象作为元素。
input.json
[
{
"features": [
{
"featureId": 1,
"feature": "feature"
}
],
"product": [
{
"id": 1,
"name": "name"
}
]
}
]
当前规格 json:
[{
"operation": "shift",
"spec": {
"*": {
"features": {
"*": {
"featureId": "[&3].&2.[&1].featureId",
"feature": "[&3].&2.[&1].feature"
}
},
"product": {
"*": {
"id": "[&3].&2.[&1].id",
"name": "[&3].&2.[&1].name"
}
}
}
}
}
]
预期输出:
[
{
"newarray": {
"features": [
{
"featureId": 1,
"feature": "feature"
}
],
"product": [
{
"id": 1,
"name": "name"
}
]
}
}
]
基本上,我想将我现有的两个数组移动到一个新对象中。提前致谢!
规格
[
{
"operation": "shift",
"spec": {
"*": { // outer array index
// match features and product which are lists
// and copy those lists to the output
"*": "[0].newarray.&"
}
}
}
]