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

#8 Reader::decodeString skips escape character '\\'

closed-fixed
nobody
None
5
2007-03-23
2006-12-08
bbcallen
No

1.this is what we have in a text file:
--jsontest.txt--
{
"special" : "\\"
}
--jsontest.txt--

2.after read it from file
--test.cpp--
...
reader.parse(buf, buf + buflen, root);
...
printf("%s", root["special"]);
--test.cpp--

3.it becomes
--echo--
\ --echo--

4.when we write it back to file, writer need TWO escape character '\\' here, but we lost one.

Discussion

  • bbcallen
    bbcallen
    2006-12-12

    Logged In: YES
    user_id=1663683
    Originator: YES

    I'm sorry, but I have not seen the patch about json_writer.cpp

    It works now.

    Thanks for ur job.
    Forgive my mistake.

     
  • Logged In: YES
    user_id=1540698
    Originator: NO

    These seems like a problem to me. I definitely see the behavior. "\\" is clearly valid, meaningful JSON, so it shoul be retained in the output.

    I have altered the writer to escape the special characters. Only unicode is not currently handled.

     
    • status: open --> closed-fixed