1、nlohmann::json
1.1 编码格式使用UTF-8
参考 nlohmann::json 中文乱码解决方案
(1)将数据先转为UTF-8格式
2、httplib
2.1 上传数据前
(1)调用httplib::Response对象的set_header()方法来设置编码格式
httplib::Response res;
res.set_header("Content-Type", "application/json; charset=utf-8");
2.2 上传数据时
(2)调用httplib::Response对象的set_content()方法时设置编码格式
json json_data = {"data" : "数据", "data2" : 123};
httplib::Response res;
std::string data = json_data.dump();
res.set_content(data, "application/json; charset=utf-8");