A library to improve Json responses in Actix-Web

Hey Rust community! For such a long time I always wanted a better way to type Actix-Web handlers that return a JSON object, but I never prioritized it to actually do something about it :sweat_smile:. So today I Just created a tiny library that exposes a helper type for this. It's use is extremely simple:

use actix_web::{get, web, Result};
use actix_json_response::JsonResponse;
use serde::Serialize;

struct MyObj {
    name: String,

async fn index(name: web::Path<String>) -> Result<JsonResponse<MyObj>> {
    let my_obj = MyObj {
        name: name.to_string(),

async fn main() -> std::io::Result<()> {
    use actix_web::{App, HttpServer};

    HttpServer::new(|| App::new().service(index))
        .bind(("", 8080))?

I hope other members of the community find it useful as well!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.