1
0
mirror of https://github.com/httpie/cli.git synced 2026-04-24 19:53:55 +02:00

Regulate top-level arrays (#1292)

* Redesign the starting path

* Do not cast `:=[1,2,3]` to a top-level array
This commit is contained in:
Batuhan Taskaya
2022-02-09 02:18:40 +03:00
committed by GitHub
parent cafa11665b
commit 225dccb218
6 changed files with 177 additions and 28 deletions
+41
View File
@@ -854,6 +854,47 @@ $ http PUT pie.dev/put \
You can also apply the nesting to the items by referencing their index:
```bash
http --offline --print=B pie.dev/post \
[0][type]=platform [0][name]=terminal \
[1][type]=platform [1][name]=desktop
```
```json
[
{
"type": "platform",
"name": "terminal"
},
{
"type": "platform",
"name": "desktop"
}
]
```
##### Escaping behavior
Nested JSON syntax uses the same [escaping rules](#escaping-rules) as
the terminal. There are 3 special characters, and 1 special token that you can escape.
If you want to send a bracket as is, escape it with a backslash (`\`):
```bash
$ http --offline --print=B pie.dev/post \
'foo\[bar\]:=1' \
'baz[\[]:=2' \
'baz[\]]:=3'
```
```json
{
"baz": {
"[": 2,
"]": 3
},
"foo[bar]": 1
}
```
If you want to send the literal backslash character (`\`), escape it with another backslash: