Hello,
I tried to parse a simple JSON-string using the method read.
The string is
string s1= "{ \"method\" : \"echo\" }";
The parsing worked well and I printed the values of the parse_info-structure.
hit=1, full=1, stop=
Then I tried to parse a string containing to objects:
string s2= "{ \"method\" : \"echo\" }{ \"method2\" : \"echo2\" }";
The string gets parsed till the end of the first object. I
can write out the resulting value, but when viewing the info-
structure I get:
hit=0, full=0, stop="{ \"method2\" : \"echo2\" }";
I've looked up the API-documentation of boost spirit:
// hit: true if parsing is successful. This may be full:
// the parser consumed all the input, or partial:
// the parser consumed only a portion of the input.
Shoud hit not be 1? Have I missed something or is there an problem in json_spirit or boost spirit?
Kind Regards,
Augustinus Topor
First of all, this is a great article. I voted it 5.
However, just to be a nitpick a little: the very first sentence of your article: JSON is an ASCII file format similar to XML, but less verbose. is not entirely correct. JSON text is Unicode, not ASCII encoded. You probably meant: JSON is a text file format...
This looks incredibly useful. I have to admit I hadn't come across JSON before reading this.
I wonder, though, have you considered the alternative approach which is to parse the data in to a (recursive) boost::variant<>, rather than do explicit type switching?