Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

New Post: Is this a bug in json::value::parse?

$
0
0
Hi Boris,

Ok there are a couple of things here so let me see if I can get them all :)

I don't consider this a bug in our JSON parser, you are passing in a string of the form "[true, false]00". While technically the zeros are after the JSON array value is closed I'd consider this still invalid. Perhaps we could ignore all characters after the top level JSON array or object is closed, but I think this is of little value.

Regarding JSON parsing tests, when I search for json::value::parse we have a lot more than just two tests covering, there are tests in json_parsing.cpp, to_and_as_operator_tests.cpp, negative_parsing_tests.cpp, iterator_tests.cpp, etc...

Ok so regarding what you are trying to accomplish, it sounds like you want to get a json::value from the response body of an HTTP GET request. The easiest way is to use the http_response::extract_json() API. All of the code you have there would become something like this:
web::json::value json = response.extract_json();
If you don't want to use extract_json() there are several other options, like reading directly from the underlying response stream. This could be done using an API like read_to_end(). Another option is to set the exact buffer you want to store the response in with the http_request::set_response_stream(...) API. Using a container_buffer backed by a string you could directly have the HTTP response body written into your string.

Steve

Viewing all articles
Browse latest Browse all 4845

Trending Articles



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