【发布时间】:2017-12-04 12:45:43
【问题描述】:
我有一个带有嵌套字段的 JSON:
[
{
"Platform Parent Dato Id": "23768",
"Platform Dato Id": "24138",
"Platform Dato Name": "Random Europe",
"Platform mission Id": "111112",
"Platform submission Id": "638687",
"Platform submission Flight Id": "863524",
"Start Date": "2017-12-01",
"End Date": "2017-12-02",
"Platform Compensation": 109.0909,
"Total Value": 909.0909,
"Goal": "200000.0000",
"Value Information": {
"Platform Compensation": [
{
"Platform mission Id": "111112",
"Platform submission Id": "638687",
"Platform submission Flight Id": "863524",
"Value Rate": "14.0000",
"Value": 109.0909
}
]
}
},
{
"Platform Parent Dato Id": "23768",
"Platform Dato Id": "24138",
"Platform Dato Name": "Random Europe",
"Platform mission Id": "111113",
"Platform submission Id": "638687",
"Platform submission Flight Id": "863524",
"Start Date": "2017-12-01",
"End Date": "2017-12-02",
"Platform Compensation": 109.0909,
"Total Value": 909.0909,
"Goal": "200000.0000",
"Value Information": {
"Platform Compensation": [
{
"Platform mission Id": "111113",
"Platform submission Id": "638687",
"Platform submission Flight Id": "863524",
"Value Rate": "12.0000",
"Value": 109.0909
}
]
}
}
]
我正在使用 JSONPATH 从Value Information 嵌套中获取Value Rate。
我在这个网站上粘贴了我的 JSON 文本:http://jsonpath.com/ 并在使用此行之后:
$[*].['Platform Compensation'].['Value Rate']
我得到了这个:
在使用这一行之后:
$.['Value Information'].['Platform Compensation'].['Platform mission Id']
我得到了这个:
我要返回(输出)的内容如下:
但我找不到正确的语法将这两者组合在一行中并通过一个 JSONPATH 查询返回两者。
【问题讨论】:
-
$.['Value Information'].['Platform Compensation'].* , this 可以帮到你
-
@Onkar 返回嵌套对象的所有字段。这很好。但是我怎样才能获得(例如)“Platform Parent Dato Id”?