Trait edm_core::extension::JsonValueExt
source · pub trait JsonValueExt {
Show 46 methods
// Required methods
fn is_ignorable(&self) -> bool;
fn as_u8(&self) -> Option<u8>;
fn as_u16(&self) -> Option<u16>;
fn as_u32(&self) -> Option<u32>;
fn as_usize(&self) -> Option<usize>;
fn as_i8(&self) -> Option<i8>;
fn as_i16(&self) -> Option<i16>;
fn as_i32(&self) -> Option<i32>;
fn as_isize(&self) -> Option<isize>;
fn as_f32(&self) -> Option<f32>;
fn as_str_array(&self) -> Option<Vec<&str>>;
fn as_map_array(&self) -> Option<Vec<&Map>>;
fn as_uuid(&self) -> Option<Uuid>;
fn as_date(&self) -> Option<Date>;
fn as_time(&self) -> Option<Time>;
fn as_datetime(&self) -> Option<DateTime>;
fn as_duration(&self) -> Option<Duration>;
fn parse_bool(&self) -> Option<Result<bool, ParseBoolError>>;
fn parse_u8(&self) -> Option<Result<u8, ParseIntError>>;
fn parse_u16(&self) -> Option<Result<u16, ParseIntError>>;
fn parse_u32(&self) -> Option<Result<u32, ParseIntError>>;
fn parse_u64(&self) -> Option<Result<u64, ParseIntError>>;
fn parse_usize(&self) -> Option<Result<usize, ParseIntError>>;
fn parse_i8(&self) -> Option<Result<i8, ParseIntError>>;
fn parse_i16(&self) -> Option<Result<i16, ParseIntError>>;
fn parse_i32(&self) -> Option<Result<i32, ParseIntError>>;
fn parse_i64(&self) -> Option<Result<i64, ParseIntError>>;
fn parse_isize(&self) -> Option<Result<isize, ParseIntError>>;
fn parse_f32(&self) -> Option<Result<f32, ParseFloatError>>;
fn parse_f64(&self) -> Option<Result<f64, ParseFloatError>>;
fn parse_string(&self) -> Option<Cow<'_, str>>;
fn parse_array<T: FromStr>(&self) -> Option<Vec<T>>;
fn parse_str_array(&self) -> Option<Vec<&str>>;
fn parse_uuid(&self) -> Option<Result<Uuid, Error>>;
fn parse_decimal(&self) -> Option<Result<Decimal, Error>>;
fn parse_date(&self) -> Option<Result<Date, ParseError>>;
fn parse_time(&self) -> Option<Result<Time, ParseError>>;
fn parse_datetime(&self) -> Option<Result<DateTime, ParseError>>;
fn parse_duration(&self) -> Option<Result<Duration, ParseDurationError>>;
fn to_string_pretty(&self) -> String;
fn to_string_unquoted(&self) -> String;
fn to_csv(&self, buffer: Vec<u8>) -> Result<Vec<u8>, Error>;
fn to_jsonlines(&self, buffer: Vec<u8>) -> Result<Vec<u8>, Error>;
fn to_msgpack(&self, buffer: Vec<u8>) -> Result<Vec<u8>, Error>;
fn into_map_array(self) -> Vec<Map>;
fn into_map_opt(self) -> Option<Map>;
}Expand description
Extension trait for serde_json::Value.
Required Methods§
sourcefn is_ignorable(&self) -> bool
fn is_ignorable(&self) -> bool
Returns true if the JSON value can be ignored.
sourcefn as_u8(&self) -> Option<u8>
fn as_u8(&self) -> Option<u8>
If the Value is an integer, represent it as u8 if possible.
Returns None otherwise.
sourcefn as_u16(&self) -> Option<u16>
fn as_u16(&self) -> Option<u16>
If the Value is an integer, represent it as u16 if possible.
Returns None otherwise.
sourcefn as_u32(&self) -> Option<u32>
fn as_u32(&self) -> Option<u32>
If the Value is an integer, represent it as u32 if possible.
Returns None otherwise.
sourcefn as_usize(&self) -> Option<usize>
fn as_usize(&self) -> Option<usize>
If the Value is an integer, represent it as usize if possible.
Returns None otherwise.
sourcefn as_i8(&self) -> Option<i8>
fn as_i8(&self) -> Option<i8>
If the Value is an integer, represent it as i8 if possible.
Returns None otherwise.
sourcefn as_i16(&self) -> Option<i16>
fn as_i16(&self) -> Option<i16>
If the Value is an integer, represent it as i16 if possible.
Returns None otherwise.
sourcefn as_i32(&self) -> Option<i32>
fn as_i32(&self) -> Option<i32>
If the Value is an integer, represent it as i32 if possible.
Returns None otherwise.
sourcefn as_isize(&self) -> Option<isize>
fn as_isize(&self) -> Option<isize>
If the Value is an integer, represent it as isize if possible.
Returns None otherwise.
sourcefn as_f32(&self) -> Option<f32>
fn as_f32(&self) -> Option<f32>
If the Value is a float, represent it as f32 if possible.
Returns None otherwise.
sourcefn as_str_array(&self) -> Option<Vec<&str>>
fn as_str_array(&self) -> Option<Vec<&str>>
If the Value is an array of strings, returns the associated vector.
Returns None otherwise.
sourcefn as_map_array(&self) -> Option<Vec<&Map>>
fn as_map_array(&self) -> Option<Vec<&Map>>
If the Value is an array of maps, returns the associated vector.
Returns None otherwise.
sourcefn as_uuid(&self) -> Option<Uuid>
fn as_uuid(&self) -> Option<Uuid>
If the Value is a String, represent it as Uuid if possible.
Returns None otherwise.
sourcefn as_date(&self) -> Option<Date>
fn as_date(&self) -> Option<Date>
If the Value is a String, represent it as Date if possible.
Returns None otherwise.
sourcefn as_time(&self) -> Option<Time>
fn as_time(&self) -> Option<Time>
If the Value is a String, represent it as Time if possible.
Returns None otherwise.
sourcefn as_datetime(&self) -> Option<DateTime>
fn as_datetime(&self) -> Option<DateTime>
If the Value is a String, represent it as DateTime if possible.
Returns None otherwise.
sourcefn as_duration(&self) -> Option<Duration>
fn as_duration(&self) -> Option<Duration>
If the Value is a String, represent it as Duration if possible.
Returns None otherwise.
sourcefn parse_bool(&self) -> Option<Result<bool, ParseBoolError>>
fn parse_bool(&self) -> Option<Result<bool, ParseBoolError>>
Parses the JSON value as bool.
sourcefn parse_usize(&self) -> Option<Result<usize, ParseIntError>>
fn parse_usize(&self) -> Option<Result<usize, ParseIntError>>
Parses the JSON value as usize.
sourcefn parse_isize(&self) -> Option<Result<isize, ParseIntError>>
fn parse_isize(&self) -> Option<Result<isize, ParseIntError>>
Parses the JSON value as isize.
sourcefn parse_string(&self) -> Option<Cow<'_, str>>
fn parse_string(&self) -> Option<Cow<'_, str>>
Parses the JSON value as Cow<'_, str>.
If the str is empty, it also returns None.
sourcefn parse_array<T: FromStr>(&self) -> Option<Vec<T>>
fn parse_array<T: FromStr>(&self) -> Option<Vec<T>>
Parses the JSON value as Vec<T>.
If the vec is empty, it also returns None.
sourcefn parse_str_array(&self) -> Option<Vec<&str>>
fn parse_str_array(&self) -> Option<Vec<&str>>
Parses the JSON value as Vec<&str>.
If the vec is empty, it also returns None.
sourcefn parse_uuid(&self) -> Option<Result<Uuid, Error>>
fn parse_uuid(&self) -> Option<Result<Uuid, Error>>
Parses the JSON value as Uuid.
If the Uuid is nil, it also returns None.
sourcefn parse_date(&self) -> Option<Result<Date, ParseError>>
fn parse_date(&self) -> Option<Result<Date, ParseError>>
Parses the JSON value as Date.
sourcefn parse_time(&self) -> Option<Result<Time, ParseError>>
fn parse_time(&self) -> Option<Result<Time, ParseError>>
Parses the JSON value as Time.
sourcefn parse_datetime(&self) -> Option<Result<DateTime, ParseError>>
fn parse_datetime(&self) -> Option<Result<DateTime, ParseError>>
Parses the JSON value as DateTime.
sourcefn parse_duration(&self) -> Option<Result<Duration, ParseDurationError>>
fn parse_duration(&self) -> Option<Result<Duration, ParseDurationError>>
Parses the JSON value as Duration.
sourcefn to_string_pretty(&self) -> String
fn to_string_pretty(&self) -> String
Returns a pretty-printed String of JSON.
sourcefn to_string_unquoted(&self) -> String
fn to_string_unquoted(&self) -> String
Returns a unquoted String of JSON.
sourcefn to_csv(&self, buffer: Vec<u8>) -> Result<Vec<u8>, Error>
fn to_csv(&self, buffer: Vec<u8>) -> Result<Vec<u8>, Error>
Attempts to convert the JSON value to the CSV bytes.
sourcefn to_jsonlines(&self, buffer: Vec<u8>) -> Result<Vec<u8>, Error>
fn to_jsonlines(&self, buffer: Vec<u8>) -> Result<Vec<u8>, Error>
Attempts to convert the JSON value to the JSON Lines bytes.
sourcefn to_msgpack(&self, buffer: Vec<u8>) -> Result<Vec<u8>, Error>
fn to_msgpack(&self, buffer: Vec<u8>) -> Result<Vec<u8>, Error>
Attempts to convert the JSON value to the MsgPack bytes.
sourcefn into_map_array(self) -> Vec<Map>
fn into_map_array(self) -> Vec<Map>
Converts self into a map array.
sourcefn into_map_opt(self) -> Option<Map>
fn into_map_opt(self) -> Option<Map>
Converts self into a map option.