1
我想張貼JSON對象使用兩個C++庫外部服務器發送nlohmann JSON有效載荷:nlohmann/json和whoshuu/cpr的最佳方式使用CPR C++請求庫
在Python中我可以做到這一點只需使用requests.post(url, json=data)
有沒有一種簡單的方法將nlohmann::json
類轉換爲cpr::Payload
等效cpr::POST
所需的等效?
我想張貼JSON對象使用兩個C++庫外部服務器發送nlohmann JSON有效載荷:nlohmann/json和whoshuu/cpr的最佳方式使用CPR C++請求庫
在Python中我可以做到這一點只需使用requests.post(url, json=data)
有沒有一種簡單的方法將nlohmann::json
類轉換爲cpr::Payload
等效cpr::POST
所需的等效?
你想去做this example from their documentation:
auto r = cpr::Post(cpr::Url{"http://www.httpbin.org/post"},
cpr::Body{"This is raw POST data"},
cpr::Header{{"Content-Type", "text/plain"}});
而不是使用cpr::Payload
的,使用cpr::Body
和JSON對象的dump()
method。