Support #2326
closedjson string encoding of '\' and other characters
0%
Description
If we parse a json string with, say, a backslash, the parser will throw an exception. It's easy enough to escape the backslash when creating the json string but I'm wondering what other characters need to be escaped (like an ampersand) and if there's already a function that provides this encoding. I don't want to re-create a wheel that is likely to exist.
More background behind this question: we're storing parameters in a json configuration file. One parameter on a Windows platform is a path and the backslash, if not escaped, will cause the parser to throw.
I tried searching the forum for 'json encode' or 'json escape' and didn't find anything relevant.
Is there an existing function to encode a json string, adding escape sequences for characters that might cause json parser exceptions?
Thanks!
Updated by Koen Deforche about 11 years ago
- Status changed from New to Resolved
- Assignee set to Koen Deforche
See answer here http://redmine.emweb.be/boards/2/topics/7851
Updated by Koen Deforche almost 11 years ago
- Status changed from Resolved to Closed