Skip to content

shipany.bot.actions.json_path_action

shipany.bot.actions.json_path_action package

Submodules

shipany.bot.actions.json_path_action.v1 module

pydantic model shipany.bot.actions.json_path_action.v1.JsonPathAction

Bases: BaseModel

Extract data from JSON using JsonPath expression.

Payload samples

Extract author from the first book in the store:

{
"name": "JsonPathAction@1",
"expression": "$.store.book[*].author",
"captures": {
"author": ""
},
"input": "{\"store\": {\"book\": [{\"author\": \"Nigel Rees\"}]}}"
}

Extract author from the first book in the store using Jinja2 template:

{
"name": "JsonPathAction@1",
"expression": "$.store.book[*].author",
"captures": {
"author": ""
},
"input": "{{response_body}}"
}

Pydantic model parameters

field name : t.Literal[‘JsonPathAction@1’] [Required]

Action name.

field expression : str [Required]

JsonPath expression

field captures : dict[str, str] [Optional]

Captures to store the matching result - key is the name of the capture, value is ignored.

Where to store the matching result. The key is the name of the capture, the value is ignored, so leave it empty. If the expression does not match anything, the capture will not be created. If the expression matches multiple values, only the first one will be captured unless you define a capture for each match.

field input_ : str [Required] (alias ‘input’)

The input to apply the expression to. It can be a JSON string or a Jinja2 template.

Module contents