Open rajatbh777 opened 2 years ago
Hi @brettz9, Can you please look into the above issue and provide any escaping logic or workaround or fix for the above issue with special characters in the JSON data key names. Thanks.
As mentioned on the main page of the README, I am not actively maintaining this project, though I am accepting PRs. Feel free to submit a well-documented PR if you find an issue and your question is not answered by the README.
Hi Team,
I am working on a project with Node.js and using “jsonpath-plus”. While using the module we’re facing certain issues-
Case-1: Special character ‘#’ when used in any of the keys in a json object and we try extracting it's value using “JSONPath” as shown in sample code below, it gives error as “TypeError: Cannot read property 'indexOf' of undefined”.
Case-2: In case when we use square brackets in any key i.e. ‘[’ or ‘]’, we’re not getting any error but rather the “console.log(resultobj)” statement in the above code gives “undefined” on the output window.
Case-3: While looking for different possible solutions I came to know that we’ll not get any error if we surround ‘#’ with parentheses i.e. ‘(’ and ‘)’ as shown in code below. Is this supposed to be a solution?
Case-4: We’re facing similar problems with other characters as well which are - ‘;’ , ‘^’ , ‘.’ , ‘~’
Code that reproduces problem here
Code for Case-1:
Code for Case-2:
Code for Case-3:
Console error or logs
Case-1 : TypeError: Cannot read property 'indexOf' of undefined
Case-2: undefined
Case-3:
Expected behavior
Case-1: It should not give any error.
Case-2: It should give an output as it is giving in Case-3.
Case-3: It is working as expected.
Case-4: It should not give any error and give output as in Case-3.
Expected result
Case-1:
Case-2:
Environment (IMPORTANT)
Desktop**
Additional context
Please update with any solution or possible workaround.