Ad Widget

Collapse

JSONPath preprocessing null values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • markfree
    Senior Member
    • Apr 2019
    • 871

    #1

    JSONPath preprocessing null values

    Zabbix 6.2 and 7.4

    Lets consider the JSON set below.

    Code:
    [
    {
    "IDENTIFIER": "123456789",
    "SEQUENCE_NO": "6",
    "EXTERNAL_SYSTEM": "SYSTEM",
    "PROCESS_DATE": "2026-04-14 00:00:00",
    "BRANCH_CODE": "LLL",
    "MODULE": "AC",
    "OPERATION": "CREATE",
    "FUNCTION_ID": "NOACBLOL",
    "ONLINE_FLAG": "Y",
    "STATUS": "S",
    "RETRY_COUNT": null,
    "ERR_CODE": null,
    "ERR_PARAMS": null,
    "ERR_MSG": null,
    "RECORD_STAT": "O",
    "AUTH_STAT": "A",
    "MOD_NO": "1",
    "MAKER_ID": "SYSTEM",
    "MAKER_DT_STAMP": "2026-04-14 00:07:33",
    "CHECKER_ID": "SYSTEM",
    "CHECKER_DT_STAMP": "2026-04-14 00:07:33",
    "ONCE_AUTH": "Y"
    },
    {
    "IDENTIFIER": "123456780",
    "SEQUENCE_NO": "6",
    "EXTERNAL_SYSTEM": "SYSTEM",
    "PROCESS_DATE": "2026-04-14 00:00:00",
    "BRANCH_CODE": "LLL",
    "MODULE": "AC",
    "OPERATION": "CREATE",
    "FUNCTION_ID": "NOACBLOL",
    "ONLINE_FLAG": "Y",
    "STATUS": "S",
    "RETRY_COUNT": null,
    "ERR_CODE": null,
    "ERR_PARAMS": null,
    "ERR_MSG": null,
    "RECORD_STAT": "O",
    "AUTH_STAT": "A",
    "MOD_NO": "1",
    "MAKER_ID": "SYSTEM",
    "MAKER_DT_STAMP": "2026-04-14 02:02:33",
    "CHECKER_ID": "SYSTEM",
    "CHECKER_DT_STAMP": "2026-04-14 02:02:33",
    "ONCE_AUTH": "Y"
    }
    ]
    Using Zabbix preprocessing, I'm trying to count the number of objects with the "STATUS" parameter equal to "S" and a non-null "ERR_PARAMS" value.
    To do so, I added the following JSONPath.

    Code:
    $.[?(@.STATUS == 'S' && @.ERR_PARAMS != 'null')].length()
    With Zabbix 6.2, I tested the preprocessing step and Zabbix returned a value of 0. (CORRECT)

    With Zabbix 7.4, I tested the preprocessing step and Zabbix returned a value of 2. (INCORRECT)

    The correct value is 0 because both JSON objects have the "ERR_PARAMS" parameter set to null.

    Setting @.ERR_PARAMS != 'null' should not be correct because the single quotes treat the value "null" as a string, which is not in the JSON object.
    When I remove the quotes from the expression, Zabbix returns me an error.

    Code:
    cannot extract value from json by path "$.[?(@.STATUS == 'S' && @.ERR_PARAMS != null)].length()": unsupported construct in jsonpath starting with: "null)].length()"
    I'm confused...
    Why would Zabbix return different values for the exact same JSONPath and exact same JSON data?

    It seems that Zabbix does not support the actual JSON nulls at all.
Working...