JsonPath:返回第一个查找 [英] JsonPath: return first find
本文介绍了JsonPath:返回第一个查找的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想检索第一个 name
次出现.
I would like to retrieve only the first name
ocurrence.
[
{
"name": "xx",
"lastname": "yy",
"child": [
{
"name": "x2"
},
{
"name": "x3"
}
]
},
{
"name": "yy",
"lastname": "xz"}
]
使用此正则表达式: $ .. name
,结果是:
with this regex: $..name
the result is:
[
"xx",
"x2",
"x3",
"yy"
]
,并且此 $ .. name [0]
是:
[
"x",
"x",
"x",
"y"
]
但是我正在寻找这个结果:
[
"xx"
]
注意:它只能在一个正则表达式中,操作后我无法将结果存储到其中
Note: it have to be in only one regex, I can't store result to after manipulate it
推荐答案
$ [0] .name会给你[
"xx"]
$[0].name
will give you
[
"xx"
]
这篇关于JsonPath:返回第一个查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文