Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

JSONNode::const_iterator i->name inco...

Help
Anonymous
2012-09-06
2013-06-12

  • Anonymous
    2012-09-06

    Hi,

    I've got libJson up and running on a particular platform. (ARM based) Running through the basic parser sample, some test JSON file returns i->name as missing the first and last characters. For example, we get the JSON file here: http://www.javascriptkit.com/dhtmltutors/javascriptkit.json, and load it into a char* buffer then libjson::parse(buffer).
    Where we'd expect "title" the lib actually returns "itl"

    I was having a look through the JSONOptions.h for line endings or any other similar options, but no such joy.

    Has anyone encountered this issue before, or could offer some advice?

    Thanks

     

  • Anonymous
    2012-09-06

    Turns out the JSON file doesn't conform to standards as it dropped the double quotes around the name. Still, I would have expected JSON_VALIDATE to have detected this?

     
  • The JSON_VALIDATE option does not validate json when you parse it, it simply exposes the libjson::is_valid method, which has to be called before parsing it.  Call this method, it will return a true or false value.

    It is likely that if you use the JSON_PREPARSE option, that version of the parser will throw a std::invalid_argument exception.  In the default parser, there is no way of knowing whether or not the json is valid because it doesn't parse it all at once.

    I hope this fixes your issue, happy coding!