Thread: [Cppcms-users] Small issues in cppcms 1.x.x
Brought to you by:
artyom-beilis
From: Daniel V. <dan...@du...> - 2010-03-15 07:05:10
|
Hello! I test successfully cppcms 1.0.0. I know that is a pre-release version, but I write this report for help. My environment is g++ (Ubuntu 4.4.3-3ubuntu1). But I get the following small issues. 1) I need add #include <stdint.h> in "session_posix_file_storage.cpp" for build the framework. 2) Is function request().http_authrization() correct spelled (whitout "a")? 3) Json parser. The json parser fail to parse a simple string. I expect that the following code snippet print "ok", but I get "err". string json_str("\"Hello World\"); cppcms::json::value v; stringstream ss; ss << json_str; v.load(ss,true); if( v.type() == cppcms::json::is_string ) { cout << "ok" << endl; } else if (v.type() == cppcms::json::is_undefined ) { cout << "err" << endl; } Thanks. |
From: Artyom <art...@ya...> - 2010-03-31 17:51:36
|
Hello, > > 3) Json parser. The json parser fail to parse a simple > string. I expect > that the following code snippet print "ok", but I get > "err". > > string json_str("\"Hello > World\"); > cppcms::json::value v; > stringstream ss; > ss << json_str; > > v.load(ss,true); > if( v.type() == > cppcms::json::is_string ) { > cout > << "ok" << endl; > } > else if (v.type() == > cppcms::json::is_undefined ) { > cout > << "err" << endl; > } > This issue was fixed in trunk among some other JSON issues. Now values are correctly handled according to JSON specifications. Artyom |
From: Artyom <art...@ya...> - 2010-04-08 20:43:30
|
Ok I've got confuses with data on json.org site. > 3) Json parser. The json parser fail to parse a simple > string. I expect > that the following code snippet print "ok", but I get > "err". > > string json_str("\"Hello > World\"); > cppcms::json::value v; > stringstream ss; > ss << json_str; > The string "Hello World" is not valid json. See RFC-4627 http://www.ietf.org/rfc/rfc4627.txt Json is either Object or Array, single values is not valid JSON. I reverted incorrect changes. Json parses should not accept such strings. Artyom |
From: Daniel V. <chi...@gm...> - 2010-04-09 15:32:12
|
Hello Artyom, The RFC says: A JSON text is a serialized object or array. JSON-text = object / array Then, you are right, JSON-text is an Object or Array only. But, the RFC says about Values: 2.1. Values A JSON value MUST be an object, array, number, or string, or one of the following three literal names: false null true Therefore the string "Hello World" is a valid Json Value syntax. I think that the cppcms::json::value parser should accept a valid Json Value syntax. If you had a class "cppcms::json::json_text" or similar, the parser of this type should only accept Object or Array syntax. As you have pointed out. Daniel. On Thu, 2010-04-08 at 13:43 -0700, Artyom wrote: > Ok I've got confuses with data on json.org site. > > > 3) Json parser. The json parser fail to parse a simple > > string. I expect > > that the following code snippet print "ok", but I get > > "err". > > > > string json_str("\"Hello > > World\"); > > cppcms::json::value v; > > stringstream ss; > > ss << json_str; > > > > The string "Hello World" is not valid json. See RFC-4627 > > http://www.ietf.org/rfc/rfc4627.txt > > Json is either Object or Array, single values is not valid JSON. > I reverted incorrect changes. Json parses should not accept such strings. > > Artyom > > > |
From: Artyom <art...@ya...> - 2010-04-09 15:48:46
|
Ok, I see, you have a point... Indeed it either should be json::text and accept text only or json::value and accept values as well. In any case... My json parser receives superset of json. It allows C++ style comments // and allows additional commas like {"foo","bar",} So I reverted the change in trunk... it receives values back again Artyom --- On Fri, 4/9/10, Daniel Vallejos <chi...@gm...> wrote: > From: Daniel Vallejos <chi...@gm...> > Subject: Re: [Cppcms-users] Small issues in cppcms 1.x.x > To: "Artyom" <art...@ya...> > Cc: cpp...@li... > Date: Friday, April 9, 2010, 6:32 PM > Hello Artyom, > > The RFC says: > > A JSON text is a serialized > object or array. > > JSON-text > = object / array > > Then, you are right, JSON-text is an Object or Array only. > > But, the RFC says about Values: > > 2.1. Values > > A JSON value > MUST be an object, array, number, or string, or one of > the following > three literal names: > > false null > true > > Therefore the string "Hello World" is a valid Json Value > syntax. I think > that the cppcms::json::value parser should accept a valid > Json Value > syntax. > > If you had a class "cppcms::json::json_text" or similar, > the parser of > this type should only accept Object or Array syntax. As you > have pointed > out. > > Daniel. > > > > On Thu, 2010-04-08 at 13:43 -0700, Artyom wrote: > > Ok I've got confuses with data on json.org site. > > > > > 3) Json parser. The json parser fail to parse a > simple > > > string. I expect > > > that the following code snippet print "ok", but I > get > > > "err". > > > > > > string > json_str("\"Hello > > > World\"); > > > > cppcms::json::value v; > > > > stringstream ss; > > > ss << > json_str; > > > > > > > The string "Hello World" is not valid json. See > RFC-4627 > > > > http://www.ietf.org/rfc/rfc4627.txt > > > > Json is either Object or Array, single values is not > valid JSON. > > I reverted incorrect changes. Json parses should not > accept such strings. > > > > Artyom > > > > > > > > > |