【发布时间】:2019-02-17 22:43:28
【问题描述】:
我有一个 json 对象数组,如下所示:
{
"testcases": {
"testcase": {
"custom-fields": {
"custom-field": [{
"@id": "testCaseID",
"@content": "shotwell15"
}, {
"#text": "-",
"@id": "casecomponent"
}, {
"#text": "critical",
"@id": "caseimportance"
}]
},
"title": "Shotwell 15"
}
}
}
我正在尝试使用 python 并根据@id 的“值”从custom-field 数组中获取对象,如下所示:
找到对象:
{
"#text": "critical",
"@id": "caseimportance"
}
基于值“caseimportance”
我尝试使用过滤器,但这似乎不起作用。我觉得不应该这么难。在 javascript 或 ruby 中很简单的事情。在 ruby 中,我可以只使用 .select 方法
【问题讨论】:
标签: python arrays json object find