JSON
Synopsis
Parses JSON strings from a specified field into structured objects.
Schema
- json:
field: <ident>
add_to_root: <boolean>
add_to_root_conflict_strategy: <enum>
allow_duplicate_keys: <boolean>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>
target_field: <ident>
Configuration
The following fields are used to define the processor:
| Field | Required | Default | Description |
|---|---|---|---|
field | Y | - | Source field containing JSON string |
add_to_root | N | false | Add parsed fields to document root |
add_to_root_conflict_strategy | Y* | - | Strategy for a root key collision: replace or merge. There is no default — with add_to_root set, an actual collision under an unset strategy fails with unsupported conflict strategy |
allow_duplicate_keys | N | false | Accepted but not applied. The value is never read; the decoder keeps the last value for a repeated key regardless |
description | N | - | Documentation note |
if | N | - | Conditional expression |
ignore_failure | N | false | Skip processing errors |
ignore_missing | N | false | Skip if input field missing |
on_failure | N | - | Error handling processors |
on_success | N | - | Success handling processors |
tag | N | - | Identifier for logging |
disabled | N | false | When true, the processor is skipped and the event continues to the next one. Lets you take a processor out of the path without removing its configuration |
* = Required only when add_to_root is set AND a key actually collides. Without a collision the strategy is never consulted.
|target_field|N|-|Output field for parsed object|
Details
The processor can either store the parsed object in a target field or merge it into the document root, with configurable strategies for handling conflicts and duplicate keys.
When add_to_root is set to true, target_field must not be set as fields are added directly to the document root.
The processor supports two strategies for handling conflicts when adding to root:
replace- Existing fields are overwritten with the new valuesmerge- Objects are merged recursively, arrays are concatenated, and primitive values are replaced
The decoder always keeps the last value for a repeated key. allow_duplicate_keys does not change that — it is read nowhere in the processor.
Examples
Basic
Parsing JSON string to object... | |
creates a structured object: | |
Adding to Root
Merging JSON into the document root... | |
replaces the existing values: | |
Merge
Merging nested objects... | |
combines existing and new values: | |
Duplicate Keys
Handling the duplicate keys in JSON... | |
keeps the last value: | |
Error Handling
Handling invalid JSON gracefully... | |
captures the error information: | |