azadkuh / gason--

an efficient JSon parser and builder in plain C++
Other
25 stars 13 forks source link

using stl string for json data? #5

Open Outstep opened 6 years ago

Outstep commented 6 years ago

Hello,

I am interested in using your modified Gason++ for a project that I am working on, but my project also uses STL and the json data is in a std::string or std::streamstring variable.

Hope can I use this as the data feed?

Thanks,

azadkuh commented 6 years ago

hi

i was working on an embedded device (few KB up to 4MB of ram) then, and the rational to use gason++ over more modern json libraries was simply the lack of proper heap support (i.e. no new, no stl or ...)

if you can use heap allocated types or classes like as std::string / stream / ... i highly recommend you to use a more modern or compliant json library as:

Outstep commented 6 years ago

Hello,

It seems that your fork, gason--, seems to work well, but on one json file that I tested


    // parsing
    gason::JsonAllocator    iallocator;

    gason::JsonValue        root;
    gason::JsonParseStatus  status = gason::jsonParse(cstr, root,

iallocator);

    // buffer will be over-written by jsonParse
    if ( status != gason::JSON_PARSE_OK ) {
        fprintf(stdout, "parsing failed! %d", static_cast<int>(status));
        rc = "Parsing Failed!! ";

    }

I am getting "parsing failed! 6" and when I looked in the gason.hpp header, I think that the 6 corresponds to "JSON_PARSE_MISMATCH_BRACKET" in

enum JsonParseStatus { JSON_PARSE_OK, JSON_PARSE_BAD_NUMBER, JSON_PARSE_BAD_STRING, JSON_PARSE_BAD_IDENTIFIER, JSON_PARSE_STACK_OVERFLOW, JSON_PARSE_STACK_UNDERFLOW, JSON_PARSE_MISMATCH_BRACKET, JSON_PARSE_UNEXPECTED_CHARACTER, JSON_PARSE_UNQUOTED_KEY, JSON_PARSE_BREAKING_BAD, JSON_PARSE_ALLOCATION_FAILURE };

Can you please tell me what might cause this error in the JSON file?

Thanks, :)

On Wed, Apr 25, 2018 at 4:51 AM, amir zamani notifications@github.com wrote:

hi

i was working on an embedded device (4MB of ram) then, and the rational to use gason++ over more modern json libraries was simply the lack of proper heap support (i.e. no new, no stl or ...)

if you can use heap allocated types or classes like as std::string / stream / ... i highly recommend you to use a more modern or compliant json library as:

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/azadkuh/gason--/issues/5#issuecomment-384212054, or mute the thread https://github.com/notifications/unsubscribe-auth/AXkxHr-bvWF4IdWB-2DZfVZkC5S693laks5tsDkpgaJpZM4TfwBP .