pub enum JsoncValue<I, F> {
    Object(MapImpl<String, JsoncValue<I, F>>),
    Array(Vec<JsoncValue<I, F>>),
    Bool(bool),
    Null,
    String(String),
    Number(Number<I, F>),
}
Expand description

Represents any valid JSON with comments value.

§Examples

see crate document also.

use json_with_comments::{jsonc_generics, value::JsoncValue};

let mut value: JsoncValue<u32, f32> = jsonc_generics!({
    "name": "json-with-comments",
    "keywords": [
        "JSON with comments",
        "JSONC",
        "trailing comma",
    ],
});

// index access
assert_eq!(value["name"], JsoncValue::String("json-with-comments".to_string()));
assert_eq!(
    value["keywords"].get(..=1),
    Some(
        &[JsoncValue::String("JSON with comments".to_string()), JsoncValue::String("JSONC".to_string())][..]
    )
);

// mutable access
value["name"] = "json_with_comments".into();
if let Some(JsoncValue::String(jsonc)) = value["keywords"].get_mut(1) {
    *jsonc = jsonc.to_lowercase();
}
assert_eq!(value, jsonc_generics!({
    "name": "json_with_comments",
    "keywords": [
        "JSON with comments",
        "jsonc",
        "trailing comma",
    ],
}));

// as rust value
let v = value["keywords"].as_vec().unwrap();
let mut iter = v.iter();
assert_eq!(iter.next().unwrap().as_str().unwrap(), "JSON with comments");
assert_eq!(iter.next().unwrap().as_str().unwrap(), "jsonc");
assert_eq!(iter.next().unwrap().as_str().unwrap(), "trailing comma");
assert_eq!(iter.next(), None);

Variants§

§

Object(MapImpl<String, JsoncValue<I, F>>)

Represents any valid JSON with comments object. Default implementation is HashMap. If preserve_order feature is enabled, that will be IndexMap.

let v = json_with_comments::jsonc!({"key": "value"});
§

Array(Vec<JsoncValue<I, F>>)

Represents any valid JSON with comments array.

let v = json_with_comments::jsonc!([1, 2, 3]);
§

Bool(bool)

Represents any valid JSON with comments boolean.

let v = json_with_comments::jsonc!(true);
§

Null

Represents any valid JSON with comments null.

let v = json_with_comments::jsonc!(null);
§

String(String)

Represents any valid JSON with comments string.

let v = json_with_comments::jsonc!("string");
§

Number(Number<I, F>)

Represents any valid JSON with comments number, whether integer or float.

let v = json_with_comments::jsonc!(123.45);

Implementations§

source§

impl<'de, I, F> JsoncValue<I, F>
where I: ToPrimitive, F: ToPrimitive,

source

pub fn into_deserialize<D>(&'de self) -> Result<D>
where D: Deserialize<'de>,

Deserialize a JsoncValue as type D.

§Examples
use serde::Deserialize;
#[derive(Deserialize)]
struct Person<'a> {
    name: &'a str,
    age: Option<u32>,
}

let target = json_with_comments::jsonc!({"name": "John", "age": 30});
let person: Person = target.into_deserialize().unwrap();
assert!(matches!(person, Person { name: "John", age: Some(30) }));
source§

impl<I, F> JsoncValue<I, F>

source

pub fn get<In: JsoncIndex<Self>>( &self, index: In ) -> Option<&<In::Indexer as JsoncIndexer<In, JsoncValue<I, F>>>::Output>

Returns a reference to the value at the given index.

  • if the value is an array, returns the element at the given index, or None if the index is out of bounds.
  • if the value is an object, returns the value associated with the given key, or None if the key is not found.
  • if the value is neither an array nor an object, returns None.
§Examples
use json_with_comments::jsonc;
let value = jsonc!({
    "array": [1, 2, 3],
    "object": {
        "key": "value",
    },
});

assert_eq!(value["array"].get(0), Some(&1.into()));
assert_eq!(value["array"].get(1..), Some(&[2.into(), 3.into()][..]));
assert_eq!(value["array"].get(1000), None);

assert_eq!(value["object"].get("key"), Some(&"value".into()));
assert_eq!(value["object"].get("nonexistent"), None);

assert_eq!(value["array"][1].get(0), None);
assert_eq!(value["object"]["key"].get(""), None);
source

pub fn get_mut<In: JsoncIndex<Self>>( &mut self, index: In ) -> Option<&mut <In::Indexer as JsoncIndexer<In, JsoncValue<I, F>>>::Output>

Returns a mutable reference to the value at the given index (see Self::get).

§Examples
use json_with_comments::{jsonc, Value, value::number::Number};
let mut value = jsonc!({
    "array": [1, 2, 3],
    "object": {
        "key": "value",
    },
});
if let Some(Value::Number(Number::Integer(i))) = value["array"].get_mut(2) {
    assert_eq!(i, &3);
    *i = *i * *i;
    assert_eq!(i, &9);
}
if let Some(v) = value["object"].get_mut("key") {
    assert_eq!(v, &Value::String("value".to_string()));
    *v = ().into();
    assert_eq!(v, &Value::Null);
}
assert_eq!(value, jsonc!({
    "array": [1, 2, 9],
    "object": {
        "key": null,
    },
}));
source§

impl<I, F> JsoncValue<I, F>

source

pub fn is_object(&self) -> bool

Returns true if the Value is an Object. Returns false otherwise.

§Examples
use json_with_comments::jsonc;
assert!(jsonc!({"key": "value"}).is_object());
assert!(!jsonc!([1, 2, 3]).is_object());
assert!(!jsonc!(true).is_object());
assert!(!jsonc!(null).is_object());
assert!(!jsonc!("string").is_object());
assert!(!jsonc!(123).is_object());
assert!(!jsonc!(123.45).is_object());
source

pub fn as_map(&self) -> Option<&MapImpl<String, Self>>

If the Value is an Object, returns the associated Map. Returns None otherwise.

§Examples
use json_with_comments::jsonc;
assert_eq!(jsonc!({"key": "value"}).as_map(), Some(&json_with_comments::value::MapImpl::from([("key".to_string(), "value".into())])));
assert_eq!(jsonc!([1, 2, 3]).as_map(), None);
assert_eq!(jsonc!(true).as_map(), None);
assert_eq!(jsonc!(null).as_map(), None);
assert_eq!(jsonc!("string").as_map(), None);
assert_eq!(jsonc!(123).as_map(), None);
assert_eq!(jsonc!(123.45).as_map(), None);
source

pub fn as_map_mut(&mut self) -> Option<&mut MapImpl<String, Self>>

If the Value is an Object, returns the associated mutable Map reference. Returns None otherwise.

§Examples
use json_with_comments::jsonc;
let mut object = jsonc!({"key": "value"});
let mut map = object.as_map_mut().unwrap();
map.insert("new_key".to_string(), "new_value".into());
assert_eq!(object, jsonc!({"key": "value", "new_key": "new_value"}));
source

pub fn is_array(&self) -> bool

Returns true if the Value is an Array. Returns false otherwise.

§Examples
use json_with_comments::jsonc;
assert!(!jsonc!({"key": "value"}).is_array());
assert!(jsonc!([1, 2, 3]).is_array());
assert!(!jsonc!(true).is_array());
assert!(!jsonc!(null).is_array());
assert!(!jsonc!("string").is_array());
assert!(!jsonc!(123).is_array());
assert!(!jsonc!(123.45).is_array());
source

pub fn as_vec(&self) -> Option<&Vec<Self>>

If the Value is an Array, returns the associated Vec. Returns None otherwise.

§Examples
use json_with_comments::jsonc;
assert_eq!(jsonc!({"key": "value"}).as_vec(), None);
assert_eq!(jsonc!([1, 2, 3]).as_vec(), Some(&vec![1.into(), 2.into(), 3.into()]));
assert_eq!(jsonc!(true).as_vec(), None);
assert_eq!(jsonc!(null).as_vec(), None);
assert_eq!(jsonc!("string").as_vec(), None);
assert_eq!(jsonc!(123).as_vec(), None);
assert_eq!(jsonc!(123.45).as_vec(), None);
source

pub fn as_vec_mut(&mut self) -> Option<&mut Vec<Self>>

If the Value is an Array, returns the associated mutable Vec reference. Returns None otherwise.

§Examples
use json_with_comments::{jsonc, to_string};
let mut array = jsonc!([1, 2, 3]);
let mut vec = array.as_vec_mut().unwrap();
vec.iter_mut().for_each(|v| *v = to_string(&v).unwrap().into());
assert_eq!(array, jsonc!(["1", "2", "3"]));
source

pub fn is_boolean(&self) -> bool

Returns true if the Value is an Boolean. Returns false otherwise.

§Examples
use json_with_comments::jsonc;
assert!(!jsonc!({"key": "value"}).is_boolean());
assert!(!jsonc!([1, 2, 3]).is_boolean());
assert!(jsonc!(true).is_boolean());
assert!(!jsonc!(null).is_boolean());
assert!(!jsonc!("string").is_boolean());
assert!(!jsonc!(123).is_boolean());
assert!(!jsonc!(123.45).is_boolean());
source

pub fn as_bool(&self) -> Option<&bool>

If the Value is an Boolean, returns the associated bool. Returns None otherwise.

§Examples
use json_with_comments::jsonc;
assert_eq!(jsonc!({"key": "value"}).as_bool(), None);
assert_eq!(jsonc!([1, 2, 3]).as_bool(), None);
assert_eq!(jsonc!(true).as_bool(), Some(&true));
assert_eq!(jsonc!(null).as_bool(), None);
assert_eq!(jsonc!("string").as_bool(), None);
assert_eq!(jsonc!(123).as_bool(), None);
assert_eq!(jsonc!(123.45).as_bool(), None);
source

pub fn as_bool_mut(&mut self) -> Option<&mut bool>

If the Value is an Boolean, returns the associated mutable bool reference. Returns None otherwise.

§Examples
use json_with_comments::jsonc;
let mut boolean = jsonc!(true);
let mut bool = boolean.as_bool_mut().unwrap();
*bool = false;
assert_eq!(boolean, jsonc!(false));
source

pub fn is_null(&self) -> bool

Returns true if the Value is an Null. Returns false otherwise.

§Examples
use json_with_comments::jsonc;
assert!(!jsonc!({"key": "value"}).is_null());
assert!(!jsonc!([1, 2, 3]).is_null());
assert!(!jsonc!(true).is_null());
assert!(jsonc!(null).is_null());
assert!(!jsonc!("string").is_null());
assert!(!jsonc!(123).is_null());
assert!(!jsonc!(123.45).is_null());
source

pub fn as_unit(&self) -> Option<()>

If the Value is an Null, returns the associated (). Returns None otherwise.

§Examples
use json_with_comments::jsonc;
assert_eq!(jsonc!({"key": "value"}).as_unit(), None);
assert_eq!(jsonc!([1, 2, 3]).as_unit(), None);
assert_eq!(jsonc!(true).as_unit(), None);
assert_eq!(jsonc!(null).as_unit(), Some(()));
assert_eq!(jsonc!("string").as_unit(), None);
assert_eq!(jsonc!(123).as_unit(), None);
assert_eq!(jsonc!(123.45).as_unit(), None);
source

pub fn is_string(&self) -> bool

Returns true if the Value is an String. Returns false otherwise.

§Examples
use json_with_comments::jsonc;
assert!(!jsonc!({"key": "value"}).is_string());
assert!(!jsonc!([1, 2, 3]).is_string());
assert!(!jsonc!(true).is_string());
assert!(!jsonc!(null).is_string());
assert!(jsonc!("string").is_string());
assert!(!jsonc!(123).is_string());
assert!(!jsonc!(123.45).is_string());
source

pub fn as_str(&self) -> Option<&str>

If the Value is an String, returns the associated str. Returns None otherwise.

§Examples
use json_with_comments::jsonc;
assert_eq!(jsonc!({"key": "value"}).as_str(), None);
assert_eq!(jsonc!([1, 2, 3]).as_str(), None);
assert_eq!(jsonc!(true).as_str(), None);
assert_eq!(jsonc!(null).as_str(), None);
assert_eq!(jsonc!("string").as_str(), Some("string"));
assert_eq!(jsonc!(123).as_str(), None);
assert_eq!(jsonc!(123.45).as_str(), None);
source

pub fn as_str_mut(&mut self) -> Option<&mut str>

If the Value is an String, returns the associated mutable str reference. Returns None otherwise.

§Examples
use json_with_comments::jsonc;
let mut boolean = jsonc!(true);
let mut bool = boolean.as_bool_mut().unwrap();
*bool = false;
assert_eq!(boolean, jsonc!(false));
source

pub fn is_number(&self) -> bool

Returns true if the Value is an Number. Returns false otherwise.

§Examples
use json_with_comments::jsonc;
assert!(!jsonc!({"key": "value"}).is_number());
assert!(!jsonc!([1, 2, 3]).is_number());
assert!(!jsonc!(true).is_number());
assert!(!jsonc!(null).is_number());
assert!(!jsonc!("string").is_number());
assert!(jsonc!(123).is_number());
assert!(jsonc!(123.45).is_number());
source

pub fn as_number(&self) -> Option<&Number<I, F>>

If the Value is an Number, returns the associated Number. Returns None otherwise.

§Examples
use json_with_comments::jsonc;
assert_eq!(jsonc!({"key": "value"}).as_number(), None);
assert_eq!(jsonc!([1, 2, 3]).as_number(), None);
assert_eq!(jsonc!(true).as_number(), None);
assert_eq!(jsonc!(null).as_number(), None);
assert_eq!(jsonc!("string").as_number(), None);
assert_eq!(jsonc!(123).as_number(), Some(&json_with_comments::value::number::Number::Integer(123)));
assert_eq!(jsonc!(123.45).as_number(), Some(&json_with_comments::value::number::Number::Float(123.45)));
source

pub fn as_number_mut(&mut self) -> Option<&mut Number<I, F>>

If the Value is an Number, returns the associated mutable Number reference. Returns None otherwise.

§Examples
use json_with_comments::jsonc;
let mut num = jsonc!(123);
let mut number = num.as_number_mut().unwrap();
*number = json_with_comments::value::number::Number::Float(123.45);
assert_eq!(num, jsonc!(123.45));
source

pub fn is_integer(&self) -> bool

Returns true if the Value is an Integer. Returns false otherwise.

§Examples
use json_with_comments::jsonc;
assert!(!jsonc!({"key": "value"}).is_integer());
assert!(!jsonc!([1, 2, 3]).is_integer());
assert!(!jsonc!(true).is_integer());
assert!(!jsonc!(null).is_integer());
assert!(!jsonc!("string").is_integer());
assert!(jsonc!(123).is_integer());
assert!(!jsonc!(123.45).is_integer());
source

pub fn as_integer(&self) -> Option<&I>

If the Value is an Integer, returns the associated I. Returns None otherwise.

§Examples
use json_with_comments::jsonc;
assert_eq!(jsonc!({"key": "value"}).as_integer(), None);
assert_eq!(jsonc!([1, 2, 3]).as_integer(), None);
assert_eq!(jsonc!(true).as_integer(), None);
assert_eq!(jsonc!(null).as_integer(), None);
assert_eq!(jsonc!("string").as_integer(), None);
assert_eq!(jsonc!(123).as_integer(), Some(&123i64));
assert_eq!(jsonc!(123.45).as_integer(), None);
source

pub fn as_integer_mut(&mut self) -> Option<&mut I>

If the Value is an Integer, returns the associated mutable I reference. Returns None otherwise.

§Examples
use json_with_comments::jsonc;
let mut integer = jsonc!(123);
let mut i = integer.as_integer_mut().unwrap();
*i = *i * *i;
assert_eq!(integer, jsonc!(15129));
source

pub fn is_float(&self) -> bool

Returns true if the Value is an Float. Returns false otherwise.

§Examples
use json_with_comments::jsonc;
assert!(!jsonc!({"key": "value"}).is_float());
assert!(!jsonc!([1, 2, 3]).is_float());
assert!(!jsonc!(true).is_float());
assert!(!jsonc!(null).is_float());
assert!(!jsonc!("string").is_float());
assert!(!jsonc!(123).is_float());
assert!(jsonc!(123.45).is_float());
source

pub fn as_float(&self) -> Option<&F>

If the Value is an Float, returns the associated F. Returns None otherwise.

§Examples
use json_with_comments::jsonc;
assert_eq!(jsonc!({"key": "value"}).as_float(), None);
assert_eq!(jsonc!([1, 2, 3]).as_float(), None);
assert_eq!(jsonc!(true).as_float(), None);
assert_eq!(jsonc!(null).as_float(), None);
assert_eq!(jsonc!("string").as_float(), None);
assert_eq!(jsonc!(123).as_float(), None);
assert_eq!(jsonc!(123.45).as_float(), Some(&123.45f64));
source

pub fn as_float_mut(&mut self) -> Option<&mut F>

If the Value is an Float, returns the associated mutable F reference. Returns None otherwise.

§Examples
use json_with_comments::jsonc;
let mut float = jsonc!(123.45);
let mut f = float.as_float_mut().unwrap();
*f = *f + *f;
assert_eq!(float, jsonc!(246.9));
source§

impl<I, F> JsoncValue<I, F>

source

pub fn from_serialize<S>(value: S) -> Result<Self>
where S: Serialize,

Serialize a JsoncValue as type S.

§Examples
use serde::Serialize;
#[derive(Serialize)]
struct Person<'a> {
    name: &'a str,
    age: Option<u32>,
}
let target = Person { name: "John", age: Some(30) };
let person = json_with_comments::Value::from_serialize(target).unwrap();
assert_eq!(person, json_with_comments::jsonc!({"name": "John", "age": 30}));
source§

impl<I, F> JsoncValue<I, F>

source

pub fn query(&self, query: &str) -> Option<&JsoncValue<I, F>>

TODO doc

source

pub fn take(&mut self) -> Self

Replaces value with the default value Null, returning the previous value.

  • If you want to replace the values of two variables, see Self::swap.
  • If you want to replace with a passed value instead of the default value, see Self::replace.
§Examples
use json_with_comments::jsonc;
let mut value = jsonc!({
    "name": "json-with-comments",
    "keywords": [
        "JSON with comments",
        "JSONC",
        "trailing comma",
    ],
});

let name = value["name"].take();
assert_eq!(name, "json-with-comments".into());
assert_eq!(value, jsonc!({
    "name": null,
    "keywords": [
        "JSON with comments",
        "JSONC",
        "trailing comma"
    ]
}));
source

pub fn swap(&mut self, other: &mut Self)

Swaps self value and other value.

  • If you want to swap with a default or dummy value, see Self::take.
  • If you want to replace with a passed value instead of the default value, see Self::replace.
§Examples
use json_with_comments::jsonc;
let mut value = jsonc!({
    "name": "json-with-comments",
    "keywords": [
        "JSON with comments",
        "JSONC",
        "trailing comma",
    ],
});

let mut lower = "jsonc".into();
let name = value["keywords"][1].swap(&mut lower);
assert_eq!(lower, "JSONC".into());
assert_eq!(value, jsonc!({
    "name": "json-with-comments",
    "keywords": [
        "JSON with comments",
        "jsonc",
        "trailing comma"
    ]
}));
source

pub fn replace(&mut self, other: Self) -> Self

Moves other value into self value, returning the previous self value.

  • If you want to swap with a default or dummy value, see Self::take.
  • If you want to replace the values of two variables, see Self::swap.
§Examples
use json_with_comments::jsonc;
let mut value = jsonc!({
    "name": "json-with-comments",
    "keywords": [
        "JSON with comments",
        "JSONC",
        "trailing comma",
    ],
});

let upper = "JSON WITH COMMENTS".into();
let original = value["keywords"][0].replace(upper);
assert_eq!(original, "JSON with comments".into());
assert_eq!(value, jsonc!({
    "name": "json-with-comments",
    "keywords": [
        "JSON WITH COMMENTS",
        "JSONC",
        "trailing comma"
    ]
}));
source

pub fn value_type(&self) -> String

Get the value type representation of JsoncValue. Main use case is for error reporting.

§Examples
use json_with_comments::jsonc;
assert_eq!(jsonc!({"key": "value"}).value_type(), "Object");
assert_eq!(jsonc!([1, 2, 3]).value_type(), "Array");
assert_eq!(jsonc!(true).value_type(), "Boolean");
assert_eq!(jsonc!(null).value_type(), "Null");
assert_eq!(jsonc!("string").value_type(), "String");
assert_eq!(jsonc!(123).value_type(), "Number");
assert_eq!(jsonc!(123.45).value_type(), "Number");

Trait Implementations§

source§

impl<I: Clone, F: Clone> Clone for JsoncValue<I, F>

source§

fn clone(&self) -> JsoncValue<I, F>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<I: Debug, F: Debug> Debug for JsoncValue<I, F>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<I, F> Default for JsoncValue<I, F>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de, I: FromPrimitive, F: FromPrimitive> Deserialize<'de> for JsoncValue<I, F>

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<I, F> From<&str> for JsoncValue<I, F>

source§

fn from(value: &str) -> Self

Converts to this type from the input type.
source§

impl<I, F> From<()> for JsoncValue<I, F>

source§

fn from(_: ()) -> Self

Converts to this type from the input type.
source§

impl<I, F> From<HashMap<String, JsoncValue<I, F>>> for JsoncValue<I, F>

source§

fn from(value: MapImpl<String, JsoncValue<I, F>>) -> Self

Converts to this type from the input type.
source§

impl<I, F> From<Number<I, F>> for JsoncValue<I, F>

source§

fn from(value: Number<I, F>) -> Self

Converts to this type from the input type.
source§

impl<I, F> From<String> for JsoncValue<I, F>

source§

fn from(value: String) -> Self

Converts to this type from the input type.
source§

impl<I, F> From<Vec<JsoncValue<I, F>>> for JsoncValue<I, F>

source§

fn from(value: Vec<JsoncValue<I, F>>) -> Self

Converts to this type from the input type.
source§

impl<I, F> From<bool> for JsoncValue<I, F>

source§

fn from(value: bool) -> Self

Converts to this type from the input type.
source§

impl<I> From<f32> for JsoncValue<I, f32>

source§

fn from(value: f32) -> Self

Converts to this type from the input type.
source§

impl<I> From<f64> for JsoncValue<I, f64>

source§

fn from(value: f64) -> Self

Converts to this type from the input type.
source§

impl<F> From<i128> for JsoncValue<i128, F>

source§

fn from(value: i128) -> Self

Converts to this type from the input type.
source§

impl<F> From<i16> for JsoncValue<i16, F>

source§

fn from(value: i16) -> Self

Converts to this type from the input type.
source§

impl<F> From<i32> for JsoncValue<i32, F>

source§

fn from(value: i32) -> Self

Converts to this type from the input type.
source§

impl<F> From<i64> for JsoncValue<i64, F>

source§

fn from(value: i64) -> Self

Converts to this type from the input type.
source§

impl<F> From<i8> for JsoncValue<i8, F>

source§

fn from(value: i8) -> Self

Converts to this type from the input type.
source§

impl<F> From<u128> for JsoncValue<u128, F>

source§

fn from(value: u128) -> Self

Converts to this type from the input type.
source§

impl<F> From<u16> for JsoncValue<u16, F>

source§

fn from(value: u16) -> Self

Converts to this type from the input type.
source§

impl<F> From<u32> for JsoncValue<u32, F>

source§

fn from(value: u32) -> Self

Converts to this type from the input type.
source§

impl<F> From<u64> for JsoncValue<u64, F>

source§

fn from(value: u64) -> Self

Converts to this type from the input type.
source§

impl<F> From<u8> for JsoncValue<u8, F>

source§

fn from(value: u8) -> Self

Converts to this type from the input type.
source§

impl<I, F> FromIterator<(String, JsoncValue<I, F>)> for JsoncValue<I, F>

source§

fn from_iter<T: IntoIterator<Item = (String, JsoncValue<I, F>)>>( iter: T ) -> Self

Creates a value from an iterator. Read more
source§

impl<I, F> FromIterator<JsoncValue<I, F>> for JsoncValue<I, F>

source§

fn from_iter<T: IntoIterator<Item = JsoncValue<I, F>>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl<I: FromPrimitive, F: FromPrimitive> FromStr for JsoncValue<I, F>

§

type Err = JsonWithCommentsError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl<I, F, In: JsoncIndex<JsoncValue<I, F>>> Index<In> for JsoncValue<I, F>

§

type Output = <<In as JsoncIndex<JsoncValue<I, F>>>::Indexer as JsoncIndexer<In, JsoncValue<I, F>>>::Output

The returned type after indexing.
source§

fn index(&self, index: In) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<I, F, In: JsoncIndex<JsoncValue<I, F>>> IndexMut<In> for JsoncValue<I, F>

source§

fn index_mut(&mut self, index: In) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<I, F> JsoncIndex<JsoncValue<I, F>> for &str

source§

impl<I, F> JsoncIndex<JsoncValue<I, F>> for Range<usize>

source§

impl<I, F> JsoncIndex<JsoncValue<I, F>> for RangeFrom<usize>

source§

impl<I, F> JsoncIndex<JsoncValue<I, F>> for RangeFull

source§

impl<I, F> JsoncIndex<JsoncValue<I, F>> for RangeInclusive<usize>

source§

impl<I, F> JsoncIndex<JsoncValue<I, F>> for RangeTo<usize>

source§

impl<I, F> JsoncIndex<JsoncValue<I, F>> for RangeToInclusive<usize>

source§

impl<I, F> JsoncIndex<JsoncValue<I, F>> for usize

source§

impl<'a, I, F> JsoncIndexer<&'a str, JsoncValue<I, F>> for StringIndexer

§

type Output = JsoncValue<I, F>

source§

fn get<'b>( value: &'b JsoncValue<I, F>, index: &'a str ) -> Option<&'b Self::Output>

source§

fn get_mut<'b>( value: &'b mut JsoncValue<I, F>, index: &'a str ) -> Option<&'b mut Self::Output>

source§

fn index<'b>(value: &'b JsoncValue<I, F>, index: &'a str) -> &'b Self::Output

source§

fn index_mut<'b>( value: &'b mut JsoncValue<I, F>, index: &'a str ) -> &'b mut Self::Output

source§

impl<I, F, S: SliceIndex<[JsoncValue<I, F>]> + JsoncIndex<JsoncValue<I, F>>> JsoncIndexer<S, JsoncValue<I, F>> for SliceIndexer

§

type Output = <S as SliceIndex<[JsoncValue<I, F>]>>::Output

source§

fn get(value: &JsoncValue<I, F>, index: S) -> Option<&Self::Output>

source§

fn get_mut(value: &mut JsoncValue<I, F>, index: S) -> Option<&mut Self::Output>

source§

fn index(value: &JsoncValue<I, F>, index: S) -> &Self::Output

source§

fn index_mut(value: &mut JsoncValue<I, F>, index: S) -> &mut Self::Output

source§

impl<I: PartialEq, F: PartialEq> PartialEq for JsoncValue<I, F>

source§

fn eq(&self, other: &JsoncValue<I, F>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<I: Serialize, F: Serialize> Serialize for JsoncValue<I, F>

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<I, F> TryFrom<JsoncValue<I, F>> for ()

§

type Error = JsonWithCommentsError

The type returned in the event of a conversion error.
source§

fn try_from(value: JsoncValue<I, F>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<I, F> TryFrom<JsoncValue<I, F>> for MapImpl<String, JsoncValue<I, F>>

§

type Error = JsonWithCommentsError

The type returned in the event of a conversion error.
source§

fn try_from(value: JsoncValue<I, F>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<I, F> TryFrom<JsoncValue<I, F>> for Number<I, F>

§

type Error = JsonWithCommentsError

The type returned in the event of a conversion error.
source§

fn try_from(value: JsoncValue<I, F>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<I, F> TryFrom<JsoncValue<I, F>> for String

§

type Error = JsonWithCommentsError

The type returned in the event of a conversion error.
source§

fn try_from(value: JsoncValue<I, F>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<I, F> TryFrom<JsoncValue<I, F>> for Vec<JsoncValue<I, F>>

§

type Error = JsonWithCommentsError

The type returned in the event of a conversion error.
source§

fn try_from(value: JsoncValue<I, F>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<I, F> TryFrom<JsoncValue<I, F>> for bool

§

type Error = JsonWithCommentsError

The type returned in the event of a conversion error.
source§

fn try_from(value: JsoncValue<I, F>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<I> TryFrom<JsoncValue<I, f32>> for f32

§

type Error = JsonWithCommentsError

The type returned in the event of a conversion error.
source§

fn try_from(value: JsoncValue<I, f32>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<I> TryFrom<JsoncValue<I, f64>> for f64

§

type Error = JsonWithCommentsError

The type returned in the event of a conversion error.
source§

fn try_from(value: JsoncValue<I, f64>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<F> TryFrom<JsoncValue<i128, F>> for i128

§

type Error = JsonWithCommentsError

The type returned in the event of a conversion error.
source§

fn try_from(value: JsoncValue<i128, F>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<F> TryFrom<JsoncValue<i16, F>> for i16

§

type Error = JsonWithCommentsError

The type returned in the event of a conversion error.
source§

fn try_from(value: JsoncValue<i16, F>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<F> TryFrom<JsoncValue<i32, F>> for i32

§

type Error = JsonWithCommentsError

The type returned in the event of a conversion error.
source§

fn try_from(value: JsoncValue<i32, F>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<F> TryFrom<JsoncValue<i64, F>> for i64

§

type Error = JsonWithCommentsError

The type returned in the event of a conversion error.
source§

fn try_from(value: JsoncValue<i64, F>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<F> TryFrom<JsoncValue<i8, F>> for i8

§

type Error = JsonWithCommentsError

The type returned in the event of a conversion error.
source§

fn try_from(value: JsoncValue<i8, F>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<F> TryFrom<JsoncValue<u128, F>> for u128

§

type Error = JsonWithCommentsError

The type returned in the event of a conversion error.
source§

fn try_from(value: JsoncValue<u128, F>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<F> TryFrom<JsoncValue<u16, F>> for u16

§

type Error = JsonWithCommentsError

The type returned in the event of a conversion error.
source§

fn try_from(value: JsoncValue<u16, F>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<F> TryFrom<JsoncValue<u32, F>> for u32

§

type Error = JsonWithCommentsError

The type returned in the event of a conversion error.
source§

fn try_from(value: JsoncValue<u32, F>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<F> TryFrom<JsoncValue<u64, F>> for u64

§

type Error = JsonWithCommentsError

The type returned in the event of a conversion error.
source§

fn try_from(value: JsoncValue<u64, F>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<F> TryFrom<JsoncValue<u8, F>> for u8

§

type Error = JsonWithCommentsError

The type returned in the event of a conversion error.
source§

fn try_from(value: JsoncValue<u8, F>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<I, F> StructuralPartialEq for JsoncValue<I, F>

Auto Trait Implementations§

§

impl<I, F> RefUnwindSafe for JsoncValue<I, F>

§

impl<I, F> Send for JsoncValue<I, F>
where F: Send, I: Send,

§

impl<I, F> Sync for JsoncValue<I, F>
where F: Sync, I: Sync,

§

impl<I, F> Unpin for JsoncValue<I, F>
where F: Unpin, I: Unpin,

§

impl<I, F> UnwindSafe for JsoncValue<I, F>
where F: UnwindSafe, I: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,