移除/删除 json 值(多个数组)
我想在数组中删除“软件3”。我对JSON数据很新,我不知道正确的方法是什么。我尝试了未设置的方法,但它不起作用。谁能告诉我这个例子。我已经搜索了该解决方案,但其中大多数没有使用多个数组。
JSON数据:
"system_info": {
"hardware": {
"model": "PowerEdge R710",
"serialno": "FG6MC2S",
"warranty": {
"warranty_start_date": "2022-03-14",
"warranty_end_date": "2025-03-14"
}
},
"operating_env": {
"os": "PowerEdge R710",
"os_version": "FG6MC2S"
},
"software_installed": [
{
"name": "Software 1",
"version": "4.5"
},
{
"name": "Software 2",
"version": "5.5"
},
{
"name": "Software 3",
"version": "5.5"
}
]},
I want to remove 'Software 3' in the array. I'm quite new with json data and I do not know what is the correct way to do it. I have tried the unset method but its not working. Can anyone show me the example. I already search the solution but most of it not using multiple array.
json data:
"system_info": {
"hardware": {
"model": "PowerEdge R710",
"serialno": "FG6MC2S",
"warranty": {
"warranty_start_date": "2022-03-14",
"warranty_end_date": "2025-03-14"
}
},
"operating_env": {
"os": "PowerEdge R710",
"os_version": "FG6MC2S"
},
"software_installed": [
{
"name": "Software 1",
"version": "4.5"
},
{
"name": "Software 2",
"version": "5.5"
},
{
"name": "Software 3",
"version": "5.5"
}
]},
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用JavaScript
Using javascript
使用Python。我假设该数据位于
data.json
remove_script.py
打印输出
output.json中
Using python. I will assume that this data lives in
data.json
remove_script.py
printed output
output.json