JsonUtils
v1.0 · OutSystems ODC External Library
JSON Escape & Unescape Utilities
.NET 8
Zero Deps
Unicode / Hebrew
ODC Compatible
ODC Server Actions have no native JSON.stringify equivalent. When you inject raw JSON — such as Excel row data, API responses, or dynamic query payloads — into an outer JSON body, unescaped quotes and control characters break the structure and cause Invalid control character decode errors.
JsonUtils provides two lightweight actions to solve this cleanly, with no external dependencies beyond the OutSystems ExternalLibraries SDK.
2.1 JsonEscape
Escapes a raw JSON string so it can be safely embedded as a value inside another JSON object or string.
Input parameter
Parameter
Type
Description
Json
Text
The raw JSON text to escape. Returns empty string when input is null or empty.
Return value
Name
Escaped
The escaped JSON string, safe for embedding as a value inside another JSON.
Characters escaped
Character
Escaped As
Order
Reason
\ (backslash)
\\
1st
Must be first to avoid double-escaping
" (double quote)
\"
2nd
Prevents breaking the enclosing JSON string
newline
\n
3rd
Control characters break JSON parsers
carriage return
\r
4th
tab
\t
5th
ℹ Order matters. Backslashes are always escaped first. If they were escaped later, the newly introduced \\ would be double-escaped.
2.2 JsonUnescape
Exact inverse of JsonEscape. Reverts a previously escaped JSON string back to its original, valid JSON form.
The escaped JSON text to revert. Returns empty string when input is null or empty.
Unescaped
The original JSON string, fully restored. Round-trip is lossless: JsonUnescape(JsonEscape(x)) = x.