json - 在 JOLT 中验证和转换数组对象
问题描述
希望根据输入数组中的活动状态输出 JSON。如果活动为真,则提供值对象。输入 :
{
"services": [
{
"active": true,
"value": "Clampable",
"key": "40300"
},
{
"active": false,
"value": "Mixed load",
"key": "40302"
}
]
}
眼镜:
[
{
"operation": "shift",
"spec": {
"services": {
"*": {
"key": {
"40302": {
"#mixed": "loading_method"
},
"40300": {
"#clampable": "loading_method"
}
}
}
}
}
}
]
输出 :
"loading_method" : [ "clampable", "mixed"]
我不希望混合值作为输出,因为状态为假。任何建议都会很棒..
解决方案
这行得通,
如果 active 为真,则移动值节点。
[
{
"operation": "shift",
"spec": {
"services": {
"*": {
"active": {
"true": {
"@(2,value)": "loading_method"
}
}
}
}
}
}
]
推荐阅读
- java - Swing GUI 中未出现组件 - 空白窗口
- javascript - addEventListener() 只执行一次
- jquery - 如何使用 jquery 从 laravel 的嵌套循环中放置数据
- mongodb - 更快的mongoimport,在气流中并行?
- haskell - 如何多态地解释类似箭头的 GADT DSL?
- android - 如何在 adb shell 中运行 C 程序?
- javascript - true 在第一次运行时没有被打印出来。相反 false 是
- excel - 如何解析 Excel IF AND 问题查询公式
- arrays - 将内存分配给数组并更改其中的值
- javascript - 刷新控件在本机反应中无法与底部选项卡导航器一起使用