crutchwalkfactory / s60-json-library

Automatically exported from code.google.com/p/s60-json-library
0 stars 0 forks source link

The S60 example, \r\n problem #13

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. With the default _LIT(KTestFormatedJson, 
"{\t\"message\":\"test1\r\ntest2\r\n\t\t\ttest3\"}");
2. and while trying to build a josn object with this string the example leaves 
with KErrNotSupported with the following lines

CJsonBuilder* jsonBuilder = CJsonBuilder::NewL();
// this will create json string representation in memory
jsonBuilder->BuildFromJsonStringL(KTestFormatedJson);

3. I checked the library and found that "TPtrC CJsonTokener::NextString(TText 
aQuote) " leaves when it found either \r or \n.

What is the expected output? What do you see instead?
It Should continue parsing the remaning string

Original issue reported on code.google.com by a.shaf3...@gmail.com on 9 Jun 2010 at 4:13

GoogleCodeExporter commented 8 years ago
You right, I will take care of it, unless you already have fixed it and can 
provide me patch or your version of the code?

Original comment by wach.piotrek on 4 Aug 2010 at 2:50

GoogleCodeExporter commented 8 years ago
I might have some code I can give you. I didn't examine the JSON standard in 
detail to see which characters should be supported. One would think that \r and 
\n could simply be skipped in the inital parsing, but I know that some JSON for 
my application had \n embedded in certain string objects. I'm fairly certain 
they were properly escaped, though.

Overall, shouldn't these 2 characters just be ignored (since they could be in 
the JSON for pretty formatting)?

Original comment by gregn...@gmail.com on 4 Aug 2010 at 6:57

GoogleCodeExporter commented 8 years ago
Yes, you are right, these 2 characters should be ignored if they are not 
properly escaped because they may have been used for pretty formatting as you 
said.

Original comment by wach.piotrek on 5 Aug 2010 at 9:18

GoogleCodeExporter commented 8 years ago
My fix is to comment(or remove) \n \r from switch in JsonTokener.cpp :

...
    for (;;) 
        {
        c = Next();     
        switch (c) 
            {
            case 0:
//          case '\n':
//          case '\r':
                User::Leave(KErrNotSupported);
...
BTW, this method is only used in CJsonParser::ParseL, where it finds closing " 
and returns enclosing string.

Regards,
Macvek

Original comment by Mac...@gmail.com on 27 Aug 2010 at 4:07