Project

General

Profile

Actions

Support #2326

closed

json string encoding of '\' and other characters

Added by Jim Fred about 11 years ago. Updated almost 11 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
10/17/2013
Due date:
% Done:

0%

Estimated time:

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!

Actions #1

Updated by Koen Deforche about 11 years ago

  • Status changed from New to Resolved
  • Assignee set to Koen Deforche
Actions #2

Updated by Koen Deforche almost 11 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF