STRING::ESCAPE_JSON 1g 2024-05-07 laplante@plcb.ca GOWEB/STRING — Escape Strings for JSON


title: “STRING::ESCAPE_JSON” version: “1g” date: 2024-05-07 section: “1g” author: “laplante@plcb.ca” category: “GOWEB/STRING”


Synopsis

string::escape_json(string)
escape_json(string)
string::escapeJson(string)
escapeJson(string)

Description

The escape_json function escapes special characters in a string so it can be safely embedded inside a JSON string value.

Characters escaped include:

This ensures that the resulting string is valid JSON and free from syntax-breaking characters.


Parameters


Examples

res={{
    escape_json("\"\n\tééèè");
    escape_json('"&<   >abc"');
}};

Returns:

res = "\"\n\tééèè"
"\"\u0026\u003c   \u003eabc\""

Author


See Also


Version History