DriveWorks Pro 18: SppJsonEscape [send feedback...]

SppJsonEscape

Escapes characters inside a JSON string representation.

Syntax

SppJsonEscape([JSON])

Where:

JSON is JSON data as text.

The following characters are escaped in this function:

  • Backspace is replaced with \b
  • Form feed is replaced with \f
  • Newline is replaced with \n
  • Carriage return is replaced with \r
  • Tab is replaced with \t
  • Double quote - "" is replaced with \"
  • Backslash is replaced with *

Example

RuleResultMeaning
SppJsonEscape(DWVariableColorJSON)
"[\n\t{\n\t\tcolors:
\"red\tand\tgreen\"
,\n\t},\n\t{\n\t\tcolors:
\"blue\tand\tyellow\"
,\n\t}\n]"
Will convert the JSON string to its escaped JSON string representation.

Example Data

The value held in the variable DWVariableColorJSON would look like the example below:

"[
    {
        colors: ""red     and     green"",
    },
    {
        colors: ""blue    and     yellow"",
    }
]"

See also:

SppJSONLoad

SppJSONToXml

SppJSONUnEscape

For more information on JSON please see Introducing JSON.

Table of Contents