-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[API Proposal]: JsonSerializer.TryReadValue(ref Utf8JsonReader) #29902
Comments
I agree, this would make things easier.
I thought so too, but then I realized there was sufficient low-level state available to work around the limitations. I actually just finished (technically it was at 3am, but who's keeping track? 😂) implementing a non-blocking, asynchronous There are some issues I ran into (which I've been filing along the way), but it's certainly doable! |
Would name this TryDeserialize() And include a TrySerialize(), because suddenly you have something too complex or self recursive references that will cause a crash unless wrapped in try/catch. when creating a library you have no control over what is being serialized, it results in so many bug reports |
Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process. This process is part of the experimental issue cleanup initiative we are currently trialing in a limited number of areas. Please share any feedback you might have in the linked issue. |
😢 |
Sad to see this being killed off |
What is this missing to get the attention of the API reviewers? I really want "Try" -methods on the serializer |
@davidfowl I realize that this is a fairly old issue, but don't the async deserialization methods address that particular use case today? FWIW this API shape is precisely how async serialization is implemented internally, but you still need to somehow marshall the deserialization stack (this is done using the |
This issue has been automatically marked |
I'd still love a PipeReader overload on DeserializeAsync. This was a workaround for that missing |
I see. We probably wouldn't be able to take a Pipes dependency on STJ, so presumably you'd need the ability to roll your own method. We should consider offering this as part of #60904. Closing in favor of that issue. |
Note that PipeReader\Writer async were in the initial commit for the serializer back in 3.0. However, due to concerns it was pulled: Original issue: #28325 |
Bring it back 🥲 |
Yeah we'd have to re-evaluate the dependency from STJ to System.IO.Pipelines. Some options:
|
Today if the JSON passed into the JsonSerializer needs to be the fully formed, this means its basically impossible to let the caller handle buffering (which is unfortunate). This seems solvable if we add a TryReadValue which would return false if the Serializer failed to Read the full object from the Utf8JsonReader.
This currently wouldn't preserve the serializer state, but it would let the caller buffer an entire JSON payload from a Stream of bytes without a surrounding envelope.
The text was updated successfully, but these errors were encountered: