You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Returning JSON is common. This would avoid adding an extra dependency in the end user's Cargo.toml and avoid some stutter (Json(json!(...))) without exposing the serde_json dependency.
The text was updated successfully, but these errors were encountered:
That's exactly the sort of thing I was planning to write myself! Really nice that it already exists. I think that crate can be used directly by wrapping the generated type in axum::Json (and documenting that people are free to write either -> Json<impl Serialize> or -> impl IntoResponse). Would you be interested in making a PR for it?
edit: Actually maybe that crate also supports borrowing as part of the json!() expression? If yes, we can't wrap the result in Json (but we can use [something like] ErasedJson from axum-extra, which would either have to be moved into axum, or be part of the macro expansion).
Feature Request
Consider adding an
axum::json!
macro that matches theserde_json
macro syntax and avoids the stutter:Motivation
Returning JSON is common. This would avoid adding an extra dependency in the end user's Cargo.toml and avoid some stutter (
Json(json!(...))
) without exposing theserde_json
dependency.The text was updated successfully, but these errors were encountered: