Skip to content

Commit 8337d74

Browse files
creideikiWagner
authored andcommitted
DOC: Document the JSON parser in Jinja2 templates
1 parent d7675bb commit 8337d74

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/user/bots.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4226,6 +4226,17 @@ Templates are in Jinja2 format with the event provided in the variable "event".
42264226
42274227
See the Jinja2 documentation at https://jinja.palletsprojects.com/ .
42284228
4229+
As an extension to the Jinja2 environment, the function "from_json" is
4230+
available for parsing JSON strings into Python structures. This is
4231+
useful if you want to handle complicated structures in the "output"
4232+
field of an event. In that case, you would start your template with a
4233+
line like::
4234+
4235+
{%- set output = from_json(event['output']) %}
4236+
4237+
and can then use "output" as a regular Python object in the rest of
4238+
the template.
4239+
42294240
Attachments are template strings, especially useful for sending
42304241
structured data. E.g. to send a JSON document including "malware.name"
42314242
and all other fields starting with "source."::

0 commit comments

Comments
 (0)