Re: [Cppcms-users] json
Brought to you by:
artyom-beilis
|
From: Artyom B. <art...@gm...> - 2016-01-23 21:07:07
|
> Let's imagine jquery requests:
> 1)
> $.ajax({
> method: "POST",
> url: "/test",
> contentType: "application/json",
> data: { "key": "test", "array": ["v1","v2","v3"] }
> })
>
> jquery sends data in post form fields something like:
> key=test&array[]=v1&array[]=v2&array[]=v3
> -> cppcms doesn't aggregate values into single json array via
> request().post("array")
> (neither "array", nor "array[]")
>
It shouldn't. If you test application/json than you should parse it as JSON
> b) request doesn't have stream interface to fill cppcms::json::value, so we
> have to deal with raw_post_data(), which is not recommended.
>
Who told you raw_post_data() isn't recommended?
> Do we have a convenient way to deal with json request?
You can just create a temporary istream from the post data and parse
the json - that is what json-rpc API does.
Also CppCMS 1.1 introduced json::parse from range of [char const *,char const *)
> Thanks.
>
Artyom
|