C++ REST (Casablanca) - web::json::value has no member named 'field_map' -


i new c++ rest ('casablanca'). read tutorial here. after than, took sample code there , tried run on machine.

below code

std::map<utility::string_t, utility::string_t> dictionary;  void handle_get(http_request request) {     trace(l"\nhandle get\n");      web::json::value::field_map answer;      (auto const & p : dictionary)     {         answer.push_back(std::make_pair(json::value(p.first), json::value(p.second)));     }      request.reply(status_codes::ok, json::value::object(answer)); }  int main() {     http_listener listener(l"http://127.0.0.1:8080/stockdata");      listener.support(methods::get, handle_get);      return 0; } 

in code, getting error below

enter image description here

i checked header file json.h , not find member (class/struct) named field_map please help

i think below code can replace code , should compile latest stable version cpprestsdk v2.8.0

std::map<utility::string_t, utility::string_t> dictionary;  void handle_get(http_request request) {     trace(l"\nhandle get\n");      json::value obj;     ( auto const & p : dictionary )     {         obj[p.first] = json::value::string(p.second);     }      // debugging     utility::stringstream_t stream;     obj.serialize(stream);     std::wcout << stream.str();      request.reply( status_codes::ok, obj); } 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -