Quantcast
Viewing all articles
Browse latest Browse all 5308

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:

Image may be NSFW.
Clik here to view.

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

For each structure, there is a AsJSON and a FromJSON

Image may be NSFW.
Clik here to view.

 

Image may be NSFW.
Clik here to view.

 

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

Image may be NSFW.
Clik here to view.

You can download the C++ client and server.


Viewing all articles
Browse latest Browse all 5308

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>