ikevin
1
If I have this code:
let results = posts.filter(published.eq(true))
.limit(5)
.load::<Post>(&connection)
.expect("Error loading posts");
as in the Diesel guide.
How do I convert the "results" to JSON for Actix Web output, like in the code below?
HttpResponse::Ok().json(results)
Thanks!
alice
2
Add the serde
crate and add a #[derive(Serialize)]
to the Post
struct. (see here for details).
If you wish to receive it as JSON too, you can derive Deserialize
.
2 Likes
system
Closed
3
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.