0

我有一个像下面这样的 JSON,并且有 JSONPath 例如,

"$[0].child_members[7].diamond.diamond_id" => Line number 55
"$[1].match_departments[0]" => Line number 83

我想在相应的 JSON 中找到 JSONPath 的行号。我正在使用 Jackson 和 JayWayPath 库,但无法弄清楚,有没有办法根据 JSONPath 找到行号。如果有人可以提出一些想法,我们将不胜感激。谢谢。

[
    {
        "facility": "Global",
        "group_names": [
            "H R"
        ],
        "group_type": "department",
        "remove_users_on_logout": false,
        "shift_membership": {
            "min": 50,
            "max": 50,
            "source": "any_shift",
            "type": [
                "auxiliary"
            ]
        },
        "child_members": [
            {
                "diamond": {
                    "diamond_id": "akron_hr"
                }
            },
            {
                "diamond": {
                    "diamond_id": "baltimore_hr"
                }
            },
            {
                "diamond": {
                    "diamond_id": "charlotte_hr"
                }
            },
            {
                "diamond": {
                    "diamond_id": "dallas_hr"
                }
            },
            {
                "diamond": {
                    "diamond_id": "elpaso_hr"
                }
            },
            {
                "diamond": {
                    "diamond_id": "houston_hr"
                }
            },
            {
                "diamond": {
                    "diamond_id": "greensboro_hr"
                }
            },
            {
                "diamond": {
                    "diamond_id": "houston_hr"
                }
            },
            {
                "diamond": {
                    "diamond_id": "knoxville_hr"
                }
            },
            {
                "diamond": {
                    "diamond_id": "lakewood_hr"
                }
            },
            {
                "diamond": {
                    "diamond_id": "madison_hr"
                }
            },
            {
                "diamond": {
                    "diamond_id": "nashville_hr"
                }
            }
        ]
    },
    {
        "facility": "Akron",
        "match_departments": [
            "L T C",
            "M I C U"
        ],
        "child_members": [
            {
                "group_names": [
                    "Unit Alert"
                ],
                "group_type": "ordinary",
                "group_use": [
                    "unit_alert"
                ],
                "remove_users_on_logout": false,
                "name_format": "$department $name",
                "shift_membership": {
                    "min": 12,
                    "max": 12,
                    "source": "per_shift",
                    "type": [
                        "clinician"
                    ]
                }
            }
        ]
    }
]
4

1 回答 1

0

“在句法元素(值和标点符号,但不在字符串值内)周围或之间允许和忽略空格。为此目的,四个特定字符被视为空格:空格、水平制表符、换行和回车。” (来源:https ://en.wikipedia.org/wiki/JSON )

由于上述原因,无法生成准确的行号,因为添加一些换行符的空格回车会更改行号,但不会更改 JSON 消息。

于 2021-08-31T06:12:26.603 回答