Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse string contains "\" or "/" errors #424

Closed
gdchnly opened this issue Jun 15, 2018 · 2 comments
Closed

Parse string contains "\" or "/" errors #424

gdchnly opened this issue Jun 15, 2018 · 2 comments

Comments

@gdchnly
Copy link

gdchnly commented Jun 15, 2018

when parse json string like {"type": "a\c"}, json_tokener_parse return NULL.
when parse json string like {"type": "a/c"}, json_object_to_json_string will return { "type": "a/c" }, there is one extra escape character

@gdchnly gdchnly changed the title Parse string contains "\" Parse string contains "\" or "/" errors Jun 15, 2018
@hawicz
Copy link
Member

hawicz commented Jun 15, 2018

That sounds fine to me. \c is not a valid escape sequence in JSON (see chapter 7 of https://tools.ietf.org/html/rfc7159.html)

If you don't want forward slashes to be escaped in the output, i.e.:

{ "type": "a\/c" }

(which seems to be what you tried to say above, but github's markdown hides the backslash), then pass the JSON_C_TO_STRING_NOSLASHESCAPE flag when calling json_object_to_json_string_ext().

@hawicz hawicz closed this as completed Jun 15, 2018
@gdchnly
Copy link
Author

gdchnly commented Jun 15, 2018

3Q, I misunderstood it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants