Ad Widget

Collapse

Advanced and nested JSONPath

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bbonno
    Junior Member
    • Apr 2025
    • 22

    #1

    Advanced and nested JSONPath

    I'm trying to combine data from two different sources, and I'm most of the way there. A calculated item concatenates my data and builds the JSON below. The idea is to do the final slicing with JSONPath preprocessing.

    The goal is to return the Code where any of the RunnerPids match myPID.

    I made a first step work on https://jsonpath.com/ and https://jsoning.com/jsonpath/, but sadly Zabbix uses a slightly different implementation of JSONPath than these. So this works on those sites, while Zabbix says there is no match (even when you misspell indexOf)
    $.list[?(@.RunnerPids.indexOf(60936) > -1 )].Code

    Finally i would be looking for something like this, but this exact construct doesn't seem to work anywhere:

    $.list[?(@.RunnerPids.indexOf($.myPID.first()) > -1)].Code.first()
    Any help would be appreciated.


    Example JSON:
    HTML Code:
    {
        "myPID": 60936,
        "list": [
            {
                "LastRunTime": "/Date(1744218794147)/",
                "Status": 7,
                "Category": "DOC",
                "IsActive": true,
                "SchedulePeriod": "PT5M",
                "ErrorCountLast24Hours": 17,
                "PlaceInQueue": 40,
                "Branch": "",
                "Code": "SRR",
                "RunningCount": 3,
                "LastErrorTime": "/Date(1744209346937)/",
                "BindingTypes": [],
                "RunnerPids": [
                    59640,
                    60936,
                    52728
                ],
                "TimeRunning": "PT22M40.801094S",
                "TimeInQueue": "PT7.5623717S",
                "NextRunTime": "/Date(1744219074000)/"
            },
            {
                "LastRunTime": "/Date(1744218786957)/",
                "Status": 7,
                "Category": "SYS",
                "IsActive": true,
                "SchedulePeriod": "PT15M",
                "ErrorCountLast24Hours": 71,
                "PlaceInQueue": 4,
                "Branch": "H91",
                "Code": "LWK",
                "RunningCount": 1,
                "LastErrorTime": "/Date(1744218555590)/",
                "BindingTypes": [
                    "StmJobQueue"
                ],
                "RunnerPids": [
                    23732
                ],
                "TimeRunning": "PT7M58.7026081S",
                "TimeInQueue": "PT1M16.31269S",
                "NextRunTime": "/Date(1744219516000)/"
            }
        ]
    }
Working...