英文:
Jolt Removing Object when value is Equal to Something
问题
以下是您提供的内容的中文翻译:
我有这样的输入 -
```json
[
{
"time": "2014-10-31T01:59:59.000+10:00",
"value": {
"nil": null
},
"metadata": {
"TVPMeasurementMetadata": {
"qualifier": {
"title": null,
"href": null
}
}
},
"longitude": "115.1248985",
"latitude": "-33.963617",
"gathered_time": "1685662804091"
},
{
"time": "2014-11-30T02:00:00.000+10:00",
"value": {
"nil": null
},
"metadata": {
"TVPMeasurementMetadata": {
"qualifier": {
"title": null,
"href": null
}
}
},
"longitude": "115.1248985",
"latitude": "-33.963617",
"gathered_time": "1685662804091"
},
{
"time": "2014-12-10T02:00:00.000+10:00",
"value": 83.939,
"metadata": null,
"longitude": "115.1248985",
"latitude": "-33.963617",
"gathered_time": "1685662804091"
},
{
"time": "2014-12-11T02:00:00.000+10:00",
"value": 84.089,
"metadata": null,
"longitude": "115.1248985",
"latitude": "-33.963617",
"gathered_time": "1685662804091"
}
]
我想要的是只获取JSON对象中包含数字数据且不等于 {"nil": null} 的值... 以下是预期的输出:
[
{
"time" : "2014-12-10T02:00:00.000+10:00",
"value" : 83.939,
"metadata" : null,
"longitude" : "115.1248985",
"latitude" : "-33.963617",
"gathered_time" : "1685662804091"
}, {
"time" : "2014-12-11T02:00:00.000+10:00",
"value" : 84.089,
"metadata" : null,
"longitude" : "115.1248985",
"latitude" : "-33.963617",
"gathered_time" : "1685662804091"
}
]
我尝试了一些不同的规格操作,如删除,但那些并没有帮助我。
<details>
<summary>英文:</summary>
I have an input like this -
[
{
"time": "2014-10-31T01:59:59.000+10:00",
"value": {
"nil": null
},
"metadata": {
"TVPMeasurementMetadata": {
"qualifier": {
"title": null,
"href": null
}
}
},
"longitude": "115.1248985",
"latitude": "-33.963617",
"gathered_time": "1685662804091"
},
{
"time": "2014-11-30T02:00:00.000+10:00",
"value": {
"nil": null
},
"metadata": {
"TVPMeasurementMetadata": {
"qualifier": {
"title": null,
"href": null
}
}
},
"longitude": "115.1248985",
"latitude": "-33.963617",
"gathered_time": "1685662804091"
},
{
"time": "2014-12-10T02:00:00.000+10:00",
"value": 83.939,
"metadata": null,
"longitude": "115.1248985",
"latitude": "-33.963617",
"gathered_time": "1685662804091"
},
{
"time": "2014-12-11T02:00:00.000+10:00",
"value": 84.089,
"metadata": null,
"longitude": "115.1248985",
"latitude": "-33.963617",
"gathered_time": "1685662804091"
}
]
What I want is to only get values the JSON objects that have numerical data in them and don't equal {"nil": null} ... Here's what the expected output looks like.
[
{
"time" : "2014-12-10T02:00:00.000+10:00",
"value" : 83.939,
"metadata" : null,
"longitude" : "115.1248985",
"latitude" : "-33.963617",
"gathered_time" : "1685662804091"
}, {
"time" : "2014-12-11T02:00:00.000+10:00",
"value" : 84.089,
"metadata" : null,
"longitude" : "115.1248985",
"latitude" : "-33.963617",
"gathered_time" : "1685662804091"
}
]
I tried a couple different specs operations like remove but those didn't get me anywhere.
</details>
# 答案1
**得分**: 3
```json
[
{
"operation": "shift",
"spec": {
"*": {
"value": {
"nil": {
"null": {
"": ""
}
},
"*": {
"@2": ""
}
}
}
}
}
]
英文:
[
{
"operation": "shift",
"spec": {
"*": {
"value": {
"nil": {
"null": {
"": ""
}
},
"*": {
"@2": ""
}
}
}
}
}
]
答案2
得分: 0
这是您的 Jolt 规范:
[
{
"operation": "modify-overwrite-beta",
"spec": {
"*": {
"value_temp": "@(1,value)",
"value_tem*": ["=toInteger", "null"]
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"value_temp": {
"*": {
"@2": "data.&1"
}
}
}
}
},
{
"operation": "remove",
"spec": {
"data": {
"null": "",
"*": {
"value_temp": ""
}
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"*": {
"*": "[#2].&"
}
}
}
}
]
英文:
This is your Jolt spec:
[
{
"operation": "modify-overwrite-beta",
"spec": {
"*": {
"value_temp": "@(1,value)",
"value_tem*": ["=toInteger", "null"]
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"value_temp": {
"*": {
"@2": "data.&1"
}
}
}
}
},
{
"operation": "remove",
"spec": {
"data": {
"null": "",
"*": {
"value_temp": ""
}
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"*": {
"*": "[#2].&"
}
}
}
}
]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论