Login to follow
JsonUtils

JsonUtils (ODC)

Stable version 0.1.0 (Compatible with ODC)
Uploaded on 1 Mar by Fábio Vaz
JsonUtils

JsonUtils (ODC)

Documentation
0.1.0

JsonUtils

v1.0 · OutSystems ODC External Library

JSON Escape & Unescape Utilities

.NET 8

Zero Deps

Unicode / Hebrew

ODC Compatible

1. Overview

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. Actions

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

Type

Description

Escaped

Text

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

Control characters break JSON parsers

tab

\t

5th

Control characters break JSON parsers

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.

Input parameter

Parameter

Type

Description

Json

Text

The escaped JSON text to revert. Returns empty string when input is null or empty.

Return value

Name

Type

Description

Unescaped

Text

The original JSON string, fully restored. Round-trip is lossless: JsonUnescape(JsonEscape(x)) = x.