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-08 15:18:40 -08: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 \
#### Advanced usage
##### Top level arrays
If you want to send an array instead of a regular object, you can simply
do that by omitting the starting key:
```bash
$ http --offline --print=B pie.dev/post \
[]:=1 \
[]:=2 \
[]:=3
```
```json
[
1,
2,
3
]
```
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