-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Deprecate JsValue::from_serde
and JsValue::into_serde
#3031
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7d0e486
Deprecate `JsValue::from_serde` and `JsValue::into_serde`
Liamolucko 874e006
fmt
Liamolucko 9bda91a
Mention JSON as an alternative to `serde-wasm-bindgen`
Liamolucko 3fde797
Use `gloo-utils` instead of raw `JSON`
Liamolucko 61766c4
Mention `gloo-utils` in API docs
Liamolucko f235bfe
Rephrase section about deprecated methods
Liamolucko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -201,6 +201,13 @@ impl JsValue { | |||||||
/// Creates a new `JsValue` from the JSON serialization of the object `t` | ||||||||
/// provided. | ||||||||
/// | ||||||||
/// **This function is deprecated**, due to [creating a dependency cycle in | ||||||||
/// some circumstances][dep-cycle-issue]. Use [`serde-wasm-bindgen`] | ||||||||
/// instead, or manually call `serde_json::to_string` + `JSON.parse`. | ||||||||
/// | ||||||||
/// [dep-cycle-issue]: https://github.com/rustwasm/wasm-bindgen/issues/2770 | ||||||||
/// [`serde-wasm-bindgen`]: https://docs.rs/serde-wasm-bindgen | ||||||||
/// | ||||||||
/// This function will serialize the provided value `t` to a JSON string, | ||||||||
/// send the JSON string to JS, parse it into a JS object, and then return | ||||||||
/// a handle to the JS object. This is unlikely to be super speedy so it's | ||||||||
|
@@ -214,6 +221,7 @@ impl JsValue { | |||||||
/// | ||||||||
/// Returns any error encountered when serializing `T` into JSON. | ||||||||
#[cfg(feature = "serde-serialize")] | ||||||||
#[deprecated = "causes dependency cycles, use `serde-wasm-bindgen` instead"] | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
pub fn from_serde<T>(t: &T) -> serde_json::Result<JsValue> | ||||||||
where | ||||||||
T: serde::ser::Serialize + ?Sized, | ||||||||
|
@@ -225,6 +233,13 @@ impl JsValue { | |||||||
/// Invokes `JSON.stringify` on this value and then parses the resulting | ||||||||
/// JSON into an arbitrary Rust value. | ||||||||
/// | ||||||||
/// **This function is deprecated**, due to [creating a dependency cycle in | ||||||||
/// some circumstances][dep-cycle-issue]. Use [`serde-wasm-bindgen`] | ||||||||
/// instead, or manually call `JSON.stringify` + `serde_json::from_str`. | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
/// | ||||||||
/// [dep-cycle-issue]: https://github.com/rustwasm/wasm-bindgen/issues/2770 | ||||||||
/// [`serde-wasm-bindgen`]: https://docs.rs/serde-wasm-bindgen | ||||||||
/// | ||||||||
/// This function will first call `JSON.stringify` on the `JsValue` itself. | ||||||||
/// The resulting string is then passed into Rust which then parses it as | ||||||||
/// JSON into the resulting value. | ||||||||
|
@@ -236,6 +251,7 @@ impl JsValue { | |||||||
/// | ||||||||
/// Returns any error encountered when parsing the JSON into a `T`. | ||||||||
#[cfg(feature = "serde-serialize")] | ||||||||
#[deprecated = "causes dependency cycles, use `serde-wasm-bindgen` instead"] | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
pub fn into_serde<T>(&self) -> serde_json::Result<T> | ||||||||
where | ||||||||
T: for<'a> serde::de::Deserialize<'a>, | ||||||||
|
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.
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.