Re: [Cppcms-users] json
Brought to you by:
artyom-beilis
From: Василий Т. <par...@gm...> - 2016-01-23 22:10:25
|
> > > 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 > I haven't dig into jquery - this is what i've got with it with such settings. I was very surpised to see form post fields in place of json with contentType: "application/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? > My bad. It looks like that was my own decision because of conditional behaviour of this method. > > > 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. > This is what i do for now. > Also CppCMS 1.1 introduced json::parse from range of [char const *,char > const *) > > Thanks a lot, i'll try this one. > > Thanks. > > > > Artyom > > > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |