This is a patch for the bug "Incorrect parsing of strings with null characters (\u0000) - ID: 3525583".
It basically includes the length of a string in Json::Value as part of the union, and in value and writer either the the pair (char*, length) or the c++ string are used.
It also modifies the writer to write \0 as \u0000.
The end result is that you can parse strings like "NUL: \u0000 end" which will return:
* Json::Value::asString() returns "NUL: \0 end" (stringn actually containing a \0 character
* Is written (writer.write or toStyledString) escaping the \u0000 character.
We're using this for JSONs containing blobs of binary data and it seems to work fine.
Please let me know where it'd best to add some tests for it - I'd more than happy to take a closer look at that.
The patch is done against 0.6.0-rc2 (r191).
Let me know what you think - Hopefully you can include this in the code :)
Log in to post a comment.