Skip to content
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

Add impl From<Number> for Value #737

Merged
merged 1 commit into from Dec 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/value/from.rs
Expand Up @@ -136,6 +136,22 @@ impl<'a> From<Cow<'a, str>> for Value {
}
}

impl From<Number> for Value {
/// Convert `Number` to `Value`
///
/// # Examples
///
/// ```
/// use serde_json::{Number, Value};
///
/// let n = Number::from(7);
/// let x: Value = n.into();
/// ```
fn from(f: Number) -> Self {
Value::Number(f)
}
}

impl From<Map<String, Value>> for Value {
/// Convert map (with string keys) to `Value`
///
Expand Down