Search code examples
c++jsonwt

Get json from Wt::Http::Request& request


I have problem with json request :( I have class

class ForumCreate : public Wt::WResource 

and function

virtual void handleRequest(const Wt::Http::Request& request, Wt::Http::Response& response)

request.contentType() is application/json. How do I get json from request?(

Maybe I should use something else to get json? Task: User send http-request with json on static url. I need to analize json file and send json-response.


Solution

  • You're going to need to parse the data from the input stream provided by

    std::istream & Wt::Http::Request::in    (       )   const
    

    https://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1Http_1_1Request.html#a768a65ceb3c0bf013b57c3de04b19041

    It should be the raw json text.