workaround serde deserializing incorrectly when arbitrary_precision enabled#521
Merged
insipx merged 6 commits intoparitytech:masterfrom Nov 22, 2019
Merged
Conversation
serde deserializes incorrectly when arbitrary precision is enabled. Fix by first deserializing into `Value` before `ClientResponse`
|
It looks like @insipx signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
tomusdrw
approved these changes
Nov 21, 2019
Contributor
tomusdrw
left a comment
There was a problem hiding this comment.
lgtm! Would be cool to get an integration test for this.
add cfg! to other places JSON is being deserialized
Contributor
Author
|
there is now a generic fn Also made sure that |
tomusdrw
approved these changes
Nov 22, 2019
| response: &str, | ||
| ) -> Result<(Id, Result<Value, RpcError>, Option<String>, Option<SubscriptionId>), RpcError> { | ||
| serde_json::from_str::<ClientResponse>(&response) | ||
| jsonrpc_core::serde_from_str::<ClientResponse>(response) |
Contributor
There was a problem hiding this comment.
Can we now get rid of serde_json dependency?
Contributor
Author
There was a problem hiding this comment.
serde_json is still used for all to_string serializations
Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
tomusdrw
approved these changes
Nov 22, 2019
koushiro
added a commit
to chainx-org/ChainX
that referenced
this pull request
Sep 17, 2020
JSON serialization/deserialization of `i128`/`u128` can only be supported when the `arbitrary_precision` feature enabled. But `arbitrary_precision` numbers don't work with `serde(tag = ..)` and `serde(flatten)` syntax (serde-rs/json#505), as a result, the deserialization of structures in `jsonrpc-core` will be error. Fortunately, the crate `jsonrpc-core` provides a workround(paritytech/jsonrpc#521). Although this workround will cause more extra serialization/deserialization work, but I think it's worth it. Signed-off-by: koushiro <koushiro.cqx@gmail.com>
ethan-rep
added a commit
to ethan-rep/ChainX
that referenced
this pull request
Sep 27, 2025
JSON serialization/deserialization of `i128`/`u128` can only be supported when the `arbitrary_precision` feature enabled. But `arbitrary_precision` numbers don't work with `serde(tag = ..)` and `serde(flatten)` syntax (serde-rs/json#505), as a result, the deserialization of structures in `jsonrpc-core` will be error. Fortunately, the crate `jsonrpc-core` provides a workround(paritytech/jsonrpc#521). Although this workround will cause more extra serialization/deserialization work, but I think it's worth it. Signed-off-by: koushiro <koushiro.cqx@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
serde deserializes incorrectly when arbitrary precision is enabled.
fixes #520
The workaround is to deserialize into
ValuebeforeClientResponse. This is gated under the featurearbitrary_precisionin core-client andtransports.