1
0
mirror of https://github.com/actix/actix-website synced 2024-11-27 18:12:57 +01:00

docs: add dependence of example (#213)

This commit is contained in:
will 2021-02-28 09:42:22 +08:00 committed by GitHub
parent de54bf6b56
commit 350fe31475
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,6 +29,19 @@ that accepts `Json<T>` as a parameter, then, you use the `.to()` method for regi
this handler. It is also possible to accept arbitrary valid json object by
using `serde_json::Value` as a type `T`.
First example of json of `JSON Request` depends on `serde`:
```toml
[dependencies]
serde = "1"
````
Second example of `JSON Request` depends on `serde` and `serde_json`:
```toml
[dependencies]
serde = "1"
serde_json = "1"
```
If you want to add default value for a field, refer to `serde`'s [documentation](https://serde.rs/attr-default.html).
{{< include-example example="requests" file="main.rs" section="json-request" >}}
You may also manually load the payload into memory and then deserialize it.