Skip to content

Conversation

killoctal
Copy link
Contributor

The problem is that having an empty json object {} is complicated to obtain because the serialization always outputs null.

With this method it is easy to have the desired output. Of course, it can be used as response or as a value.

#include "crow.h"

int main()
{
    MyProgram program;
    crow::SimpleApp app;

    // This route will return "{}" instead of "null"
    CROW_ROUTE(app, "/notify-alive")([](){
        program.notify_alive();
        return crow::json::wvalue::empty_object();
    });

    app.port(18080).run();
}

…alue (outputs "{}" instead of a "null" string)
@mrozigor mrozigor merged commit 215834f into CrowCpp:master Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants