Skip to content

Commit f7160a5

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

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
@@ -1509,15 +1509,72 @@ Converts a JSON string into a structured JSON object.
15091509
| `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.
15101510
|======
15111511

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

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

0 commit comments

Comments
 (0)