Skip to content

Commit 0e67240

Browse files
committed
Update docs
1 parent bfbe1ec commit 0e67240

File tree

1 file changed

+67
-63
lines changed

1 file changed

+67
-63
lines changed

docs/custom-actions/action-types.md

+67-63
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,74 @@
11
## Text
22

3+
### Extract JSON
4+
5+
This action automatically converts all JSON properties/fields to Variables.
6+
7+
<figure markdown="span">
8+
![Extract JSON in action](/images/custom-actions.png){ width="300" }
9+
<figcaption>Auto JSON in action</figcaption>
10+
</figure>
11+
12+
Per default, the action works on the JSON found in the `$request.content$` variable, e.g. the request body data.
13+
14+
If the JSONPath parameter is specified, this can be used to limit the variable creation to only the subset of data specified by the JSONPath query.
15+
16+
##### Extract JSON Example
17+
18+
If the following data is specified in the Source parameter:
19+
20+
```json
21+
{
22+
"Actors": [
23+
{
24+
"name": "Tom Cruise",
25+
"age": 56,
26+
"Born At": "Syracuse, NY",
27+
"Birthdate": "July 3, 1962",
28+
"photo": "https://jsonformatter.org/img/tom-cruise.jpg"
29+
},
30+
{
31+
"name": "Robert Downey Jr.",
32+
"age": 53,
33+
"Born At": "New York City, NY",
34+
"Birthdate": "April 4, 1965",
35+
"photo": "https://jsonformatter.org/img/Robert-Downey-Jr.jpg"
36+
}
37+
]
38+
}
39+
```
40+
41+
If the JSONPath parameter is empty, the following 10 variables will be created:
42+
43+
| Variable Name | Value |
44+
|-----------------------------|----------------------------------------------------|
45+
| `$json.Actors.0.name$ ` | Tom Cruise |
46+
| `$json.Actors.0.age$ ` | 56 |
47+
| `$json.Actors.0.Born At$ ` | Syracuse, NY |
48+
| `$json.Actors.0.Birthdate$` | July 3, 1962 |
49+
| `$json.Actors.0.photo$ ` | https://example.com/tom-cruise.jpg |
50+
| `$json.Actors.1.name$ ` | Robert Downey Jr. |
51+
| `$json.Actors.1.age$ ` | 53 |
52+
| `$json.Actors.1.Born At$ ` | New York City, NY |
53+
| `$json.Actors.1.Birthdate$` | April 4, 1965 |
54+
| `$json.Actors.1.photo$ ` | https://example.com/Robert-Downey-Jr.jpg |
55+
56+
If the JSONPath parameter is set to `.Actors.0`, only the following 5 variables are created:
57+
58+
| Variable Name | Value |
59+
|-----------------------------|----------------------------------------------------|
60+
| `$json.0.name$ ` | Tom Cruise |
61+
| `$json.0.age$ ` | 56 |
62+
| `$json.0.Born At$ ` | Syracuse, NY |
63+
| `$json.0.Birthdate$` | July 3, 1962 |
64+
| `$json.0.photo$ ` | https://example.com/tom-cruise.jpg |
65+
366
### Extract JSONPath
467

68+
69+
!!! warning
70+
We recommend using the *Extract JSON* action as it supports creating multiple variables in one go, saving you from creating duplicate actions.
71+
572
This action runs a JSONPath query on the contents of a request. With it, you can extract any data from a JSON document and store it in a variable, which can then be used in a downstream action.
673

774
JSONPath is very similar to the `jq` commandline utility.
@@ -72,69 +139,6 @@ For more details on what's possible with JSONPath, [take a look at the docs](htt
72139

73140
As you start entering a JSONPath, the results are validated and shown next to the input field.
74141

75-
### Extract JSON
76-
77-
This action automatically converts all JSON properties/fields to Variables.
78-
79-
<figure markdown="span">
80-
![Extract JSON in action](/images/custom-actions.png){ width="300" }
81-
<figcaption>Auto JSON in action</figcaption>
82-
</figure>
83-
84-
Per default, the action works on the JSON found in the `$request.content$` variable, e.g. the request body data.
85-
86-
If the JSONPath parameter is specified, this can be used to limit the variable creation to only the subset of data specified by the JSONPath query.
87-
88-
##### Extract JSON Example
89-
90-
If the following data is specified in the Source parameter:
91-
92-
```json
93-
{
94-
"Actors": [
95-
{
96-
"name": "Tom Cruise",
97-
"age": 56,
98-
"Born At": "Syracuse, NY",
99-
"Birthdate": "July 3, 1962",
100-
"photo": "https://jsonformatter.org/img/tom-cruise.jpg"
101-
},
102-
{
103-
"name": "Robert Downey Jr.",
104-
"age": 53,
105-
"Born At": "New York City, NY",
106-
"Birthdate": "April 4, 1965",
107-
"photo": "https://jsonformatter.org/img/Robert-Downey-Jr.jpg"
108-
}
109-
]
110-
}
111-
```
112-
113-
If the JSONPath parameter is empty, the following 10 variables will be created:
114-
115-
| Variable Name | Value |
116-
|-----------------------------|----------------------------------------------------|
117-
| `$json.Actors.0.name$ ` | Tom Cruise |
118-
| `$json.Actors.0.age$ ` | 56 |
119-
| `$json.Actors.0.Born At$ ` | Syracuse, NY |
120-
| `$json.Actors.0.Birthdate$` | July 3, 1962 |
121-
| `$json.Actors.0.photo$ ` | https://example.com/tom-cruise.jpg |
122-
| `$json.Actors.1.name$ ` | Robert Downey Jr. |
123-
| `$json.Actors.1.age$ ` | 53 |
124-
| `$json.Actors.1.Born At$ ` | New York City, NY |
125-
| `$json.Actors.1.Birthdate$` | April 4, 1965 |
126-
| `$json.Actors.1.photo$ ` | https://example.com/Robert-Downey-Jr.jpg |
127-
128-
If the JSONPath parameter is set to `.Actors.0`, only the following 5 variables are created:
129-
130-
| Variable Name | Value |
131-
|-----------------------------|----------------------------------------------------|
132-
| `$json.0.name$ ` | Tom Cruise |
133-
| `$json.0.age$ ` | 56 |
134-
| `$json.0.Born At$ ` | Syracuse, NY |
135-
| `$json.0.Birthdate$` | July 3, 1962 |
136-
| `$json.0.photo$ ` | https://example.com/tom-cruise.jpg |
137-
138142
### Extract Regex
139143

140144
This action runs a Regex (regular expression) query on the contents of a request. With it, you can extract any data from a text document and store it in a variable, which can then be used in a downstream action.

0 commit comments

Comments
 (0)