Skip to content

Commit 3ff014d

Browse files
GlenRSmithnik9000
authored andcommitted
ingest-node.asciidoc - Clarify json processor (#21876)
Add examples for the json processor.
1 parent db0a5e4 commit 3ff014d

File tree

1 file changed

+59
-2
lines changed

1 file changed

+59
-2
lines changed

docs/reference/ingest/ingest-node.asciidoc

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,15 +1510,72 @@ Converts a JSON string into a structured JSON object.
15101510
| `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.
15111511
|======
15121512

1513+
Suppose you provide this configuration of the `json` processor:
1514+
1515+
[source,js]
1516+
--------------------------------------------------
1517+
{
1518+
"json" : {
1519+
"field" : "string_source",
1520+
"target_field" : "json_target"
1521+
}
1522+
}
1523+
--------------------------------------------------
1524+
1525+
If the following document is processed:
1526+
1527+
[source,js]
1528+
--------------------------------------------------
1529+
{
1530+
"string_source": "{\"foo\": 2000}"
1531+
}
1532+
--------------------------------------------------
1533+
1534+
after the `json` processor operates on it, it will look like:
1535+
15131536
[source,js]
15141537
--------------------------------------------------
15151538
{
1516-
"json": {
1517-
"field": "{\"foo\": 2000}"
1539+
"string_source": "{\"foo\": 2000}",
1540+
"json_target": {
1541+
"foo": 2000
15181542
}
15191543
}
15201544
--------------------------------------------------
15211545

1546+
If the following configuration is provided, omitting the optional `target_field` setting:
1547+
[source,js]
1548+
--------------------------------------------------
1549+
{
1550+
"json" : {
1551+
"field" : "source_and_target"
1552+
}
1553+
}
1554+
--------------------------------------------------
1555+
1556+
then after the `json` processor operates on this document:
1557+
1558+
[source,js]
1559+
--------------------------------------------------
1560+
{
1561+
"source_and_target": "{\"foo\": 2000}"
1562+
}
1563+
--------------------------------------------------
1564+
1565+
it will look like:
1566+
1567+
[source,js]
1568+
--------------------------------------------------
1569+
{
1570+
"source_and_target": {
1571+
"foo": 2000
1572+
}
1573+
}
1574+
--------------------------------------------------
1575+
1576+
This illustrates that, unless it is explicitly named in the processor configuration, the `target_field`
1577+
is the same field provided in the required `field` configuration.
1578+
15221579
[[kv-processor]]
15231580
=== KV Processor
15241581
This processor helps automatically parse messages (or specific event fields) which are of the foo=bar variety.

0 commit comments

Comments
 (0)