cpprest-sdk

cpprest with japanese character?

假装没事ソ 提交于 2019-12-25 00:07:31
问题 The following code: auto nullValue = json::value::null(); std::string searchText = conversions::to_utf8string("michael"); make_request(client, methods::GET, nullValue, searchText); Returns the json data: {"data":[ { "_id":172,"name":"Michael Edano","profile_picture":null }], "success":true } But if i put Japanese string: auto nullValue = json::value::null(); std::string searchText = conversions::to_utf8string("北島 美奈"); make_request(client, methods::GET, nullValue, searchText); The output is:

How to iterate through json objects with cpprest

ぐ巨炮叔叔 提交于 2019-12-24 23:45:13
问题 I have a "jvalue" variable that holds a json data: { "data": [ { "_id": 123, "name": "Name 1" }, { "_id": 124, "name": "Name 2" } ], "success": true } This is my code that i tried: auto data = jvalue.at(U("data")).at(0); auto dataObj = data.as_object(); for (auto iterInner = dataObj.cbegin(); iterInner != dataObj.cend(); ++iterInner) { auto &propertyName = iterInner->first; auto &propertyValue = iterInner->second; std::wcout << "Property: " << propertyName << ", Value: " << propertyValue <<

How to extract specific data returned from web::json::value::serialize() with cpprestsdk/casablanca

别说谁变了你拦得住时间么 提交于 2019-12-24 15:33:29
问题 I have this code: wcout << jvalue.serialize() << endl; which prints out the whole body of json data: { "data": { "timestamp": [ { "_id": "5ad93fc48084e1089cd9667b", "staff_id": 172, "staff_name": "Michael Edano", "time_in": "2018-04-20T01:17:56.787Z", "time_out": null, "status": ['Leave','Vacation','Absent'], "createdAt": "2018-04-20T01:17:56.790Z", "updatedAt": "2018-04-20T01:17:56.790Z", "__v": 0 } ], "success": true } } Can someone give me an example on how to get let say the _id field and

Mutex is not supported when compiling with /clr or clr:pure (cpprestsdk aka casablanca)

岁酱吖の 提交于 2019-12-24 03:05:00
问题 I create a CLR project in visual c++ with 64 bit configuration, and try to use cpprestsdk aka casablanca 64bit . But when I run the project, an error occured: 1>------ Build started: Project: Timestamp, Configuration: Debug x64 ------ 1>MyForm.cpp 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.13.26128\include\mutex(8): fatal error C1189: #error: <mutex> is not supported when compiling with /clr or /clr:pure. 1>Testapi.cpp 1>c:\program files (x86)\microsoft

Dealing with kanji characters in C++

南楼画角 提交于 2019-12-13 12:34:59
问题 I have a windows deskop application (named: Timestamp) written in C++ that use .NET called CLR. I also have DLL project (named: Amscpprest) written in native c++ and uses CPPREST SDK to get json data from server and pass the data to my Timestamp app. Here's the scenario: This is the return json data from my server, its a list of staff name and most of it is japanese names written in Kanji characters. [ { "staff": { "id": 121, "name": "福士 達哉", "department": [ { "_id": 3, "name": "事業推進本部" } ] }

CMake errors when building cpprestsdk

醉酒当歌 提交于 2019-12-12 04:45:17
问题 I'm trying to build cpprestsdk (https://github.com/Microsoft/cpprestsdk) under MSYS2. With pacman I installed the required dependencies: boost openssl But I get the following output: $ cmake -G "MSYS Makefiles" .. -DCMAKE_BUILD_TYPE=Release -- Setting gcc options -- Added test library httpclient_test -- Added test library httplistener_test -- Added test library json_test -- Added test library pplx_test -- Added test library streams_test -- Added test library uri_test -- Added test library

http_client of cpprestsdk/casablanca

大城市里の小女人 提交于 2019-12-12 00:47:20
问题 I have api https://api.gm-system.net/api/authenticate/searchStaffs/searchText which return a list staff. And here is my code to access this api using cpprestsdk with c++. auto fileStream = std::make_shared<ostream>(); // Open stream to output file. pplx::task<void> requestTask = fstream::open_ostream(U("results.html")).then([=](ostream outFile) { *fileStream = outFile; // Create http_client to send the request. http_client client(U("https://api.gm-system.net/api/authenticate/searchStaffs

Server-side-event C++ implementation?

北城余情 提交于 2019-12-11 13:07:30
问题 I'm trying to implement a C++ server to generate event for a javascript EventSource, I'm building it with cpprest. From the examples I've seen in PHP or Node.js, it looked pretty straight-forward but I must be missing something since I'm getting this in the Firefox console: Firefox can’t establish a connection to the server at http://localhost:32123/data. With Postman, I'm correctly receiving "data : test" so I think I'm missing some continuation, probably have to do something more than just

Cannot build a cmake project in Visual Studio and vcpkg (fatal error C1083)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-09 22:50:16
问题 I installed vcpkg today, enabled integration with Visual Studio, ie .\vcpkg integrate install, and started installing libraries. I basically installed cpprestsdk and that trigger installation of boost libraries. Then I opened the project in the Visual Studio (CMake). When I installed cpprestsdk I received this message: The package cpprestsdk:x86-windows provides CMake targets: find_package(cpprestsdk REQUIRED) # Note: 1 targets were omitted target_link_libraries(main PRIVATE cpprestsdk:

how to convert utf8 to std::string?

喜欢而已 提交于 2019-12-08 01:55:14
问题 I am working on this code which receives a cpprest sdk response containing a base64_encoded payload which is a json. here is my code snippet: typedef std::wstring string_t; //defined in basic_types.h in cpprest lib void demo() { http_response response; //code to handle respose ... json::value output= response.extract_json(); string_t payload = output.at(L"payload").as_string(); vector<unsigned char> base64_encoded_payload = conversions::from_base64(payload); std::string utf8_payload(base64