Articles in this section

jsonEncode helper

Use jsonEncode to produce a string output without surrounding quotes if you pass in a string field. This helper is designed primarily for string fields and will return the same literal value for non-string inputs (e.g., numbers, booleans)—but will convert objects or arrays to "[object Object]" rather than JSON. If you need true JSON serialization of objects or arrays, consider jsonSerialize.

{{jsonEncode field}}
  • field can be a string, number, boolean, or other type. If it’s not a string, the literal value is returned. Objects/arrays become "[object Object]".

Usage

{{jsonEncode field}}
  • field can be a string, number, boolean, or other type. If it’s not a string, the literal value is returned. Objects/arrays become "[object Object]".

Examples

  1. Encoding a string field 

    {{jsonEncode record.email}}
    • If record.email is "jane.doe@example.com", the output is jane.doe@example.com (notice no quotes).

  2. Passing a numeric field 

    {{jsonEncode record.total}}
    • If record.total is 89.99, the output is 89.99.

  3. Passing an object 

    {{jsonEncode record}}
    • If record is { "customerId": "CUST123" }, the output is "[object Object]" rather than valid JSON.

Tip

  • Use jsonEncode only when you specifically want a string field without extra quotes; be cautious when passing objects or arrays.

  • If your downstream system requires fully structured JSON for objects, use a helper that preserves JSON structure rather than returning "[object Object]".

  • Double braces vs. triple braces typically do not affect jsonEncode output—this helper removes quotes around strings by design.