在使用jolt转换json键值对时,保留一些json键值对
我刚开始学习震动。我想将json转换为所需的格式。我几乎完成了,但仍坚持这一点 我的输入json看起来像在使用jolt转换json键值对时,保留一些json键值对,json,jolt,Json,Jolt,我刚开始学习震动。我想将json转换为所需的格式。我几乎完成了,但仍坚持这一点 我的输入json看起来像 { "first_name": { "label": "First name", "type": "text", "value": "John" }, "last_name": { "label": "Last name", "type": "text", "value": "Doe" }, "email": { "la
{ "first_name": {
"label": "First name",
"type": "text",
"value": "John"
},
"last_name": {
"label": "Last name",
"type": "text",
"value": "Doe"
},
"email": {
"label": "Email",
"type": "text",
"value": "johndoe@gmail.com"
}
"id": 123,
"marital_status": "Single",
"author_id": null,
"company": null,
"address": {
"city": {
"label": "city",
"dom_type": "dropdown",
"value": "test"
},
"state": {
"label": "state",
"dom_type": "dropdown",
"value": "state"
},
"country": {
"label": "country",
"dom_type": "dropdown",
"value": "country"
}
}
}
转换为这样的输出格式
{
"first_name" : "John", "last_name" : "Doe", "email" : "johndoe@gmail.com",
"id": 123, "marital_status": "Single", "author_id": null, "company": null,
"address" : { "city" : "test", "state" : "test", "country" : "test" }
}
我已经试过了
[
{
"operation": "shift",
"spec": {
"address": {
"*": {
"@value": "address.&1"
}
},
"*": {
"@value": "&1"
}
}
}
]
得到
{
"first_name" : "John", "last_name" : "Doe", "email" : "johndoe@gmail.com", "address" : { "city" : "test", "state" : "test", "country" : "test" }
}
因为匹配器“*”丢弃简单的键值对。我知道我错过了什么。有什么帮助吗?因为匹配器“*”丢弃简单的键值对。->它不是丢弃它们,而是匹配它们,但没有找到“value”的子属性
您的输入数据基本上有3种不同的格式
谢谢你的解决方案。我可以像找到子属性那样进一步自定义它吗?执行此操作,否则执行此操作。不指定单数字段键。
[
{
"operation": "shift",
"spec": {
"address": {
"*": {
"@value": "address.&1"
}
},
"id|marital_status|author_id|company": "&",
"*": {
"@value": "&1"
}
}
}
]