Search code examples
jsonoauth-2.0

Is there a way to tell the json-smart parser not to escape forward slashes?


I'm receiving Oauth2.0 tokens that have forward slashes in them with the content type set to application/json in the response headers. The Nimbus OAuth 2.0 SDK I'm using relies on this particular json library. Since it escapes forward slashes my tokens end up containing "\/" instead of "/". I know I could replace all offending instances, or substitute a UUID for "/" -- is there a way to simply tell the parser not to escape the slashes in the first place? Gson seems to have this functionality with its disableHtmlEscaping() method.


Solution

  • myJSONObject.toJSONString(new JSONStyle(JSONStyle.FLAG_PROTECT_4WEB)) passes slashes through undisturbed.