Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lacks ending quotation before the end of string #120

Open
GoogleCodeExporter opened this issue May 17, 2015 · 1 comment
Open

lacks ending quotation before the end of string #120

GoogleCodeExporter opened this issue May 17, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

Hi

I'm getting 'lacks ending quotation before the end of string' error in line 
document.ParseInsitu<0>(buffer).HasParseError()

Here is my code

Document document;

#if 0
    // "normal" parsing, decode strings to new buffers. Can use other input stream via ParseStream().
    if (document.Parse<0>(json).HasParseError())
        return 1;
#else
    // In-situ parsing, decode strings directly in the source string. Source must be string.
    char buffer[sizeof(json_string)];
    memcpy(buffer, json_string, sizeof(json_string));
    if (document.ParseInsitu<0>(buffer).HasParseError())
    {
        const char * error = document.ParseInsitu<0>(buffer).GetParseError();
        return "";
    }

#endif

    if (!document.IsNull())
    {
        if (document.HasMember("access_token"))
        {
            return document["access_token"].GetString();
        }
    }


and here is the json

{
    "access_token": "mytoken",
    "expires_in": 3600,
    "token_type": "Bearer",
    "scope": "token",
    "refresh_token": "mytoken"
}

It's valid json.

Please advise!

Original issue reported on code.google.com by [email protected] on 31 Mar 2015 at 9:06

@GoogleCodeExporter
Copy link
Author

What's the definition of "json_string"? Maybe your "sizeof(json_string)" if 
wrong?

The parsing code you used is copied from the tutorial. But (mem)copying the 
buffer before doing insitu parsing usually doesn't make much sense in real 
code. I'd suggest that you just do the "normal" parsing instead.

Original comment by [email protected] on 3 Apr 2015 at 8:34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant