json string encoding of '\' and other characters
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?