line21c / google-api-dotnet-client

Automatically exported from code.google.com/p/google-api-dotnet-client
Apache License 2.0
0 stars 0 forks source link

json - escaped \" in strings #30

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This json failed because of the escaped quote in there

source":"\u003Ca href=\"http:\/\/blackberry.com\/twitter\" 
rel=\"nofollow\"\u003ETwitter for BlackBerry\u00ae\u003C\/a\u003E"

changing GetNextToken quote case to this:
case '"':
            token.type = JsonToken.Type.String;
            // let's read in the string
            sb = new StringBuilder(BuilderBufferSize);
            char next = (char)reader.Read();
            char current = '"';

            while (!(next == '"' && current != '\\'))
            {
              sb.Append(next);
              current = next;
              next = (char)reader.Read();
            }
            token.value = sb.ToString();

            break;

Fixed it for me

Original issue reported on code.google.com by daniel.t...@gmail.com on 1 May 2011 at 9:19

GoogleCodeExporter commented 9 years ago

Original comment by davidwat...@google.com on 4 May 2011 at 10:11

GoogleCodeExporter commented 9 years ago

Original comment by davidwat...@google.com on 4 May 2011 at 10:54

GoogleCodeExporter commented 9 years ago
Hi Daniel,
I have added a test using the string you provided and it passes, looking at the 
code change you suggested I think you may have out of date source code, try 
getting the latest version and see if that solve the problem for you. 

If this is still an issue with the lastest code please update this bug saying 
so, if you could provide a unit tests that fails that would be the best, See 
examples in GoogleApis.Tests.Json.TokenStreamTest.cs.

Thanks again.

David.

Original comment by davidwat...@google.com on 4 May 2011 at 12:25

GoogleCodeExporter commented 9 years ago
Sorry, you're quite right, I have a version before ParseString was introduced. 
I'm not sure how I managed that.

Many thanks for the speedy response 

Original comment by daniel.t...@gmail.com on 4 May 2011 at 12:34