-
Notifications
You must be signed in to change notification settings - Fork 59
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
De-Escaping strings using a provided buffer #83
De-Escaping strings using a provided buffer #83
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the work on this, its intriguing functionality. I have a few questions listed in-line below.
… case specifying if a buffer is required
`from_str_using_string_unescape_buffer` => `from_str_escaped` `from_slice_using_string_unescape_buffer` => `from_slice_escaped`
… the input when deserializing, and has an iterator of unescaped fragments. Useful for zero-copy deserialization.
Pending a doc update here, this all looks good to me! Sorry for the sporadic reviews, I've been quite busy recently. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks!
Any chance you could publish a release so that I can integrate JSON deserialization into |
Indeed, I'll publish a release as soon as #91 gets reviewed. I also realized that this only handles de-serializing escaped strings, but we still don't have any support for serializing them with escaping. I'll add an issue for this. Thanks for the work on this! |
I'm unsure about the rationale behind this (very big) change. Why is this approach preferrable over the one in |
This can be achieved using
Deserializing a struct with a
This would involve |
Why is there a need for deviation from the Isn't this case (
Sure. That's inherent.
That's not what I mean. I'm proposing (1) making your change look a bit more like the I agree that a scratch buffer is needed (and it should be optional and borrowed, not owned, just as you implement it). I just don't get the other deviations from the |
Suppose that a user wishes to deserialize a structure containing a list of strings, some of which may include escape sequences when JSON encoded. Without |
Right. This is an allocator! The real-world cases where the maximum sum of lengths is known to be significantly less than the sum of maximum lengths such that this makes a difference are exceedingly exotic. It doesn't justify the practical disadvantages and unergonomics of having to keep the allocator arena alive and having to reason about its size. |
Here's a partial implementation of the design suggested in #79 (comment)_
An example usage of the new design can be seen at https://github.com/sammhicks/picoserve/tree/json-parse-demo