开发者社区> 问答> 正文

我正在尝试为jolt转换创建一个json,但是我对嵌套数组格式很迷惑

我正在尝试变换 jolt,但在嵌套数组中遇到了问题。我没有得到描述值。我把一些代码JSON输入是

{ "id": 3,
"name": "Sample Product", "attribute_set_id": 4, "custom_attributes": [ { "attribute_code": "image", "value": "/1/_/1.jpg" },
{ "attribute_code": "description", "value": "

This is Sample Product for test

" }
]
} 我的Jolt Spec是

[ { "operation": "shift", "spec": { "id": "id",
"name": "name", "description": "custom_attributes[0].attribute_code.value" } ] 我的预期输出是

{ "id" : 3, "name" : "Sample Product", "description" : "

This is Sample Product for test

" }

展开
收起
小六码奴 2019-10-03 19:33:43 835 0
1 条回答
写回答
取消 提交回答
  • 如果"attribute_code": "description"总是出现在数组的第二个元素中,则可以使用以下Jolt Spec来简单地转换给定的JSON字符串:

    [ { "operation": "shift", "spec": { "id": "id", "name": "name", "custom_attributes": { "1": { "value": "description" } } } } ]

    2019-10-09 16:23:10
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载