JSON processor

Converts a JSON string into a structured JSON object.

Table 25. Json Options

NameRequiredDefaultDescription

field

yes

-

The field to be parsed

target_field

no

field

The field to insert the converted structured object into

add_to_root

no

false

Flag that forces the serialized json to be injected into the top level of the document. target_field must not be set when this option is chosen.

if

no

-

Conditionally execute this processor.

on_failure

no

-

Handle failures for this processor. See Handling Failures in Pipelines.

ignore_failure

no

false

Ignore failures for this processor. See Handling Failures in Pipelines.

tag

no

-

An identifier for this processor. Useful for debugging and metrics.

All JSON-supported types will be parsed (null, boolean, number, array, object, string).

Suppose you provide this configuration of the json processor:

  1. {
  2. "json" : {
  3. "field" : "string_source",
  4. "target_field" : "json_target"
  5. }
  6. }

If the following document is processed:

  1. {
  2. "string_source": "{\"foo\": 2000}"
  3. }

after the json processor operates on it, it will look like:

  1. {
  2. "string_source": "{\"foo\": 2000}",
  3. "json_target": {
  4. "foo": 2000
  5. }
  6. }

If the following configuration is provided, omitting the optional target_field setting:

  1. {
  2. "json" : {
  3. "field" : "source_and_target"
  4. }
  5. }

then after the json processor operates on this document:

  1. {
  2. "source_and_target": "{\"foo\": 2000}"
  3. }

it will look like:

  1. {
  2. "source_and_target": {
  3. "foo": 2000
  4. }
  5. }

This illustrates that, unless it is explicitly named in the processor configuration, the target_field is the same field provided in the required field configuration.