I have a JSON response given below
我在下面给出了JSON响应
[
{
"level3": "level3Value1",
"level4": "level4value1"
},
{
"level3": "level3Value2",
"level4": "level4value2"
},
{
"level3": "level3Value3",
"level4": "level4value3"
},
{
"level3": "level3Value4",
"level4": "level4value4"
},
{
"level3": "level3Value5",
"level4": "level4value5"
}
]
I need to select level4value
based on level3value
using JsonSlurper.
我需要使用JsonSlurper基于level3value选择level4value。
1 个解决方案
#1
1
use find
to get the list element containining your desired key/value pair
使用find获取包含所需键/值对的列表元素
println([["level3": "level3Value3", "level4": "level4value3"],
["level3": "level3Value4", "level4": "level4value4"],
].find{ it.level4=='level4value4' }.level3)
#1
1
use find
to get the list element containining your desired key/value pair
使用find获取包含所需键/值对的列表元素
println([["level3": "level3Value3", "level4": "level4value3"],
["level3": "level3Value4", "level4": "level4value4"],
].find{ it.level4=='level4value4' }.level3)