Skip to content

StringToJSONString

Convert a string to a JSON-escaped string.

Declaration

Source position: fpjson.pp line 799

function StringToJSONString(const S: TJSONStringType; 
                           Strict: Boolean=False) : TJSONStringType;
function StringToJSONString(const S: UnicodeString; 
                           Strict: Boolean=False) : TJSONStringType;

Description

StringToJSONString examines the string S and replaces any special characters by an escaped string, as in the JSON specification. The following characters are escaped:

\ "  #8 #9 #10 #12 #13.

Strict indicates that only the absolutely necessary characters will be escaped (when set to True) when convering string values to JSON If set to False/ will also be escaped, although this is strictly speaking not necessary.

See also

Name Description
JSONStringToString Convert a JSON-escaped string to a string.
JSONTypeName Convert a JSON type to a string.