在C/C++中实现JSON RESTful服务的方法

jll*_*dra 21 c c++ json web-services

我试图用C/C++做一个JSON Restful Web服务.我已经尝试过Axis2/C和Staff,它非常适合XML序列化/反序列化,但不适用于JSON.

Phi*_*ipp 11

您可能想看看Herb Sutter博客中介绍的卡萨布兰卡.


Ran*_*d0m 7

尝试 https://github.com/babelouest/ulfius很棒的库来构建 C/C++ Restful API。可以支持所有平台:Linux、FreeBSD、Windows 等


Sha*_*him 7

有少数库支持使用 c 创建休息服务,例如restinio

#include <restinio/all.hpp>
int main()
{
    restinio::run(
        restinio::on_this_thread()
        .port(8080)
        .address("localhost")
        .request_handler([](auto req) {
            return req->create_response().set_body("Hello, World!").done();
        }));
    return 0;
}
Run Code Online (Sandbox Code Playgroud)


Rut*_*tix 3

您可以查看ffead-cpp。除了提供对 json 和 Restfull Web 服务的支持之外,它还包含更多功能。不过,这个框架对于您的情况来说可能太重了。