我正在尝试使用 JSONata 在以下 JSON 的“选项”数组中附加一个额外的对象:
{
"description": "[IGNORE] Field used for testing",
"displayOrder": 2,
"fieldType": "select",
"formField": true,
"groupName": "excell_data",
"label": "Dev Test Field [IGNORE]",
"name": "dev_test_field",
"options": [
{
"description": "Choice number one",
"displayOrder": 1,
"hidden": false,
"label": "Option 1",
"value": "1"
},
{
"description": "Choice number two",
"displayOrder": 2,
"hidden": false,
"label": "Option 2",
"value": "2"
},
{
"description": "Choice option three",
"displayOrder": 3,
"hidden": false,
"label": "Option 3",
"value": "3"
}
],
"type": "enumeration"
}
这样就变成了:
{
"description": "[IGNORE] Field used for testing",
"displayOrder": 2,
"fieldType": "select",
"formField": true,
"groupName": "excell_data",
"label": "Dev Test Field [IGNORE]",
"name": "dev_test_field",
"options": [
{
"description": "Choice number one",
"displayOrder": 1,
"hidden": false,
"label": "Option 1",
"value": "1"
},
{
"description": "Choice number two",
"displayOrder": 2,
"hidden": false,
"label": "Option 2",
"value": "2"
},
{
"description": "Choice option three",
"displayOrder": 3,
"hidden": false,
"label": "Option 3",
"value": "3"
},
{
"description": "Choice number four",
"displayOrder": 4,
"hidden": false,
"label": "Option 4",
"value": 4
}
],
"type": "enumeration"
}
但是,当我尝试使用 append 函数时,我很难返回父 JSON 以及嵌套在其中的附加对象。
JSONata fiddler 链接在这里:https ://try.jsonata.org/iv7zhPZcr
谁能阐明我哪里出错了?
提前谢谢了。乔纳森