次の方法で共有


Returning JSON data from a REST Web Server

To return data on a rest web server, you have to provide JSON data file format. To illustrate the sample (see my previous post), I have decided to return a simple structure:

  • std::vector<People> peoples
  • utility::string_t job

The People structure contains just:

  • utility::string_t name
  • double age

I have made a little modification on my PUT handler to return data:

The last piece of code is the code that produce the AsJSON() function call.

For each structure, there is a AsJSON and a FromJSON

 

 

You can see the result on the console output of the server. On the client side, ask the method called 'leave'.

You can download the full C++ solution here. Only C++ client or server.