JSONPath
February 18, 2022
[Fixed ] : JsonPath -> How do you parse JSON with a colon in the name?
Recently, I encountered a problem where when in my JSON response, a key came with a colon in it.
When I tried to get the value of this key with the help of JSONPath, I encountered an issue as inside the string I was not able to get it.
For Example:
{ "title": "value1", "link": "value2", "media:info": "value3" }If you want to get the first value from it, you can extract :
$.title
It will return "value1".
But if you will try to do the same for the third key, it wouldn't work because of the colon
in it.
It will return "value1".
But if you will try to do the same for the third key, it wouldn't work because of the colon
in it.
So in this case, if you would like to access it:
$.['media:info']
It will return the value.
Same then you can use it in your json Path library java code also.