Skip to content

Commit

Permalink
Impl FromStr for Value.
Browse files Browse the repository at this point in the history
  • Loading branch information
timothee-haudebourg committed Feb 21, 2024
1 parent 876d5e7 commit 19f5e2e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "json-syntax"
version = "0.12.0"
version = "0.12.1"
edition = "2021"
authors = ["Timothée Haudebourg <author@haudebourg.net>"]
description = "Strict JSON parsing and mapping library"
Expand Down
10 changes: 9 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
//! ```
pub use json_number::{InvalidNumber, Number};
use smallvec::SmallVec;
use std::fmt;
use std::{fmt, str::FromStr};

pub mod code_map;
pub mod object;
Expand Down Expand Up @@ -542,6 +542,14 @@ impl From<Object> for Value {
}
}

impl FromStr for Value {
type Err = parse::Error;

fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(Self::parse_str(s)?.0)
}
}

macro_rules! from_integer {
($($ty:ident),*) => {
$(
Expand Down

0 comments on commit 19f5e2e

Please sign in to comment.