The jsonParse helper parses a valid JSON string and returns the resulting object or object array. Use it when working with API responses or data fields that store JSON text but need to be accessed as objects.
{{{jsonParse string}}}
-
string (required): A valid JSON string
Note
Returns object/[object] verify that your AFE field supports objects and object arrays.
Parse a JSON string into an object
{{{jsonParse record.string}}}
Input:
{
"record": {
"string": "{\"foo\": \"bar\"}"
}
}
Output:
{ "foo": "bar" }
Extract a primitive from a stringified JSON
/api/v2/users.json?page[size]?shardid={{#with (jsonParse record.payload)}}{{shardid}}{{/with}}
Input:
{ "record": { "payload": "{\"shardid\":\"dddt22\"}" } }
Output:
/api/v2/users.json?page[size]?shardid=dddt22
Extract a child object from stringified JSON into requestBody
{{#with (jsonParse record.payload)}}{{{jsonStringify event}}}{{/with}}
Input:
{
"record": {
"payload": "{\"event\":{\"type\":\"create\",\"source\":\"api\"},\"id\":[123,456,789],\"status\":\"success\"}"
}
}
Output:
{"type":"create","source":"api"}
Iterate a stringified JSON array
{{#each (jsonParse record.roles)}}
{{@index}}: {{this}}
{{/each}}
Input:
{ "record": { "roles": "[\"system\",\"admin\",\"editor\",\"contributor\",\"viewer\",\"vendor\"]" } }
Output:
0: system 1: admin 2: editor 3: contributor 4: viewer 5: vendor
Tip
-
The input must be valid JSON (keys in double quotes, properly escaped).
-
Useful for parsing API responses, webhooks, or stored JSON payloads.
-
Use the
#withblock helper around jsonParse for property access:{{#with (jsonParse record.payload)}}{{name}}{{/with}}. -
Field types matter: Verify datatype of AFE field while using
jsonParse-
Stringified JSON auto-deserializes, so
jsonParseis usually not required. -
Textual fields like relative URI and mapper expressions use
jsonParseto extract primitives/iterate.
-