[ZBX-18651] JSON / JSONPATH escaped value causing unsupported construct in jsonpath Created: 2020 Nov 13  Updated: 2020 Nov 17  Resolved: 2020 Nov 17

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Templates (T)
Affects Version/s: 5.0.5
Fix Version/s: None

Type: Incident report Priority: Trivial
Reporter: Evren Yurtesen Assignee: Zabbix Development Team
Resolution: Won't fix Votes: 0
Labels: escape, jsonpath, template, unescape
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: JPEG File zabbix_jsonpath_bug.jpg    

 Description   

Steps to reproduce:

  1. Go to item preprocessing and enter JSONPath.
  2. Use parameter
$.value.['{#JMXOBJ}']
  1. Use value:
    {
      "value":{
        "name=\"PC|Ernesto\" enabled":"5"
      }
    }
    
  1. In test section use macro JMXOBJ as
name=\"PC|Ernesto\" enabled

Result:
**

cannot extract value from json by path 
"$.value.['name=\"PC|Ernesto\" enabled']": unsupported construct in 
jsonpath starting with: "\"PC|Ernesto\" enabled']"

Expected:
5

The beginning of the issue is that I am collecting JMX attributes as JSON

        {
            "{#JMXVALUE}":"5",
            "{#JMXTYPE}":"java.lang.Integer",
            "{#JMXOBJ}":"name=\"PC|Ernesto\" enabled",
            "{#JMXDESC}":"Attribute exposed for management",
            "{#JMXATTR}":"Value"
        },

 

The {#JMXOBJ} is escaped by default.  There is no way to unescape it when giving it to item prototype.



 Comments   
Comment by Alexander Vladishev [ 2020 Nov 17 ]

This works as described in the documentation. There is nothing to fix.

Please user double quotes instead of single:

$.value.["{#JMXOBJ}"]
Comment by Evren Yurtesen [ 2020 Nov 17 ]

@sasha thank you very much. I saw that manual before but did not realize the difference in quotes. I think my confusion is because at many other examples only single quotes are used. Eg.

https://goessner.net/articles/JsonPath/index.html

Including zabbix manual:

https://www.zabbix.com/documentation/5.0/manual/config/items/preprocessing/jsonpath_functionality#overview

Generated at Sun Apr 06 12:57:52 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.