[英]How to trasform a Json list to a key-value object
I have a Json with this structure: 我有一个具有以下结构的Json:
{"code":"0000",
"usercode":"sample",
"specifications":{
"c":"d","e":"f"
}}
I need to build a jolt to convert the json to this form: 我需要建立一个颠簸来将json转换为这种形式:
{"code":"0000",
"usercode":"sample",
"specifications":[
{"key":"c",
"value":"d"},
{"key":"e",
"value":"f"}
]}
I tried this, but is my first jolt. 我试过了,但这是我的第一个震动。
[
{
"operation": "shift",
"spec": {
"code": "code",
"usercode": "usercode",
"specifications": {
"*": {
"key": "@c",
"value": "@d"
}
}
}
}
]
First check this example: https://jolt-demo.appspot.com/#mapToList to understand whats going on :) 首先检查以下示例: https : //jolt-demo.appspot.com/#mapToList以了解发生了什么:)
This spec will do the trick: 该规范将达到目的:
[
{
"operation": "shift",
"spec": {
"code": "&",
"usercode": "&",
"specifications": {
"*": {
"$": "&2[#2].key",
"@": "&2[#2].value"
}
}
}
}
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.