JSON serialization with forward slash '/'
See original GitHub issueHope all is well!
Just updated to the latest release and noticed an issue with JSON serialization. The following:
map {
'uri': "test/test"
} => json:serialize()
results in:
{ "uri": "test\/test" }
I would have expected:
{ "uri": "test/test" }
Cheers!
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (4 by maintainers)
Top Results From Across the Web
JSON: why are forward slashes escaped? - Stack Overflow
The JSON spec says you CAN escape forward slash, but you don't have to.
Read more >IT16439: JSON PARSER ESCAPES FORWARD SLASHES ...
When serializing a message tree the JSON parser escapes forward slash characters so that values such as "http://myURI" appear as.
Read more >Ability to serialise JSON without escaping forward slashes #381
According to the description at https://www.json.org/json-en.html, unescaped forward slashes (solidus) are legal characters in the JSON ...
Read more >JSON serialize issue for field names containing slash `/` [Call ...
Hello everyone, I am using kernel method while converting internal table content to JSON. However, if there is a `/` character in the...
Read more >SerializeJson() Escapes Forward-Slashes In ColdFusion
This is a bug in the implementation of serializeJson(), most likely due to Adobe misreading the JSON spec/RFC. Slashes don't need to be...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
http://docs.basex.org/wiki/JSON#json:serialize Version 8.4 Updated: unescape changed to escape.
That must have changed recently? Never worked like that before nor does it any other JSON library I use including Javascript itself, any browser or .NET. I don’t use Java much so maybe that’s the catch.
For example in node or any browser this works as expected:
resulting in
{ uri: "test/test"}
How would I produce: { “uri”: “http://test.com/test”, }
Hopefully we can go with the XQuery spec as the JSON one is wonky and there is no need for this escaping which most libraries ignore.
The only argument for doing this is easily embedding JSON in script tags, but it seems silly to enforce a rule for a process that is rarely done. I don’t think I have ever embedded JSON in a script tag. 😃
it would be great if there was a way to decide which to use, like an option.
Cheers either way!