技术需求:使用JOLT Transform提取JSON Payload的content部分
用JOLT Transform提取指定content字段的配置方案
输入JSON
{ "snippet-format": "empty-snippet", "total": 361, "start": 1, "page-length": 5, "selected": "include", "results": [ { "index": 1, "uri": "/DEV/xyz-xyzRecord/OS1.json", "path": "fn:doc(\"/SIT1/xyz-xyzRecord/AB1.json\")", "score": 0, "confidence": 0, "fitness": 0, "href": "/v1/documents?uri=%2FDEV%2FIxyz-xyzRecord%2FOS1.json&database=data-hub-DEV", "mimetype": "application/json", "format": "json", "matches": null, "extracted": { "kind": "array", "content": [ { "xyz": "AB1" } ] } } ] }
期望输出
[ { "xyz": "AB1" } ]
对应的JOLT SPEC配置
[ { "operation": "shift", "spec": { "results": { "0": { "extracted": { "content": "[]" } } } } } ]
说明
这个shift操作会定位到输入JSON中results数组的第一个元素,提取其extracted.content字段,并将该数组直接映射到输出的根节点,正好得到需要的结果。
内容的提问来源于stack exchange,提问作者Sushanth
相关产品推荐
相关产品推荐

