英文:
Json string to Json using Java and Jolt
问题
我有一个 JSON 字符串,例如:
{ "value": "{\"userSuspended\":false}" }
请问正确的 Jolt 规范是什么,可以将 'userSuspended' 映射到 'state' 吗?
英文:
I have a json string e.g..
{ "value": "{\"userSuspended\":false}" }
What would be the correct Jolt spec to map 'userSuspended' to 'state'?
答案1
得分: 1
- Shift "Value" to "Value"
- 通过一个 Java 类将键 'userSuspended' 和 'false' 映射为键值对
- Shift 输出为 "userSuspended" 到 "State"
英文:
It needed two transforms and a Javaclass to map the key/value:
- Shift "Value":"Value"
- Map the keys 'userSuspended' and 'false' through a javaclass to key/value pairs
- Shift the output to "userSuspended":"State"
答案2
得分: 0
一种方法是将值拆分并保存您想要声明的内容。
[
{
"operation": "modify-overwrite-beta",
"spec": {
"stateArray": "=split(''', @(1, value))"
}
},
{
"operation": "shift",
"spec": {
"stateArray": {
"1": "state"
}
}
}
]
英文:
One way of doing it is to split the value and save what you wanted to state.
[
{
"operation": "modify-overwrite-beta",
"spec": {
"stateArray": "=split('\"',@(1,value))"
}
},
{
"operation": "shift",
"spec": {
"stateArray": {
"1": "state"
}
}
}
]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论