Skip to content
Advertisement

JSONPatch escape slash ‘/’ from JSONPatch+JSON

I’ve below JSON and I wanted to update few fields from it

JavaScript

using postman PATCH API call with below JSONPatch payload API is working fine

JavaScript

But, I want to implement same using Java .. I tried

JavaScript

It evaluates to :

JavaScript

This doc mentioned that http://jsonpatch.com/#json-pointer we MUST use escape the characters with ~0 and ~1 but no luck yet, I escaped / using ~1 i.e. "~1config~1version" but it evaluates to "/~01config~01version"

Advertisement

Answer

I think the problem is in the JsonPointer definition. Please, try something like that instead:

JavaScript

Or, equivalently:

JavaScript

Please, see this test, it provides guidance about how to tactically build JsonPointers and the meaning of escaping reserved chars.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement