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§

source

fn is_ignorable(&self) -> bool

Returns true if the JSON value can be ignored.

source

fn as_u8(&self) -> Option<u8>

If the Value is an integer, represent it as u8 if possible. Returns None otherwise.

source

fn as_u16(&self) -> Option<u16>

If the Value is an integer, represent it as u16 if possible. Returns None otherwise.

source

fn as_u32(&self) -> Option<u32>

If the Value is an integer, represent it as u32 if possible. Returns None otherwise.

source

fn as_usize(&self) -> Option<usize>

If the Value is an integer, represent it as usize if possible. Returns None otherwise.

source

fn as_i8(&self) -> Option<i8>

If the Value is an integer, represent it as i8 if possible. Returns None otherwise.

source

fn as_i16(&self) -> Option<i16>

If the Value is an integer, represent it as i16 if possible. Returns None otherwise.

source

fn as_i32(&self) -> Option<i32>

If the Value is an integer, represent it as i32 if possible. Returns None otherwise.

source

fn as_isize(&self) -> Option<isize>

If the Value is an integer, represent it as isize if possible. Returns None otherwise.

source

fn as_f32(&self) -> Option<f32>

If the Value is a float, represent it as f32 if possible. Returns None otherwise.

source

fn as_str_array(&self) -> Option<Vec<&str>>

If the Value is an array of strings, returns the associated vector. Returns None otherwise.

source

fn as_map_array(&self) -> Option<Vec<&Map>>

If the Value is an array of maps, returns the associated vector. Returns None otherwise.

source

fn as_uuid(&self) -> Option<Uuid>

If the Value is a String, represent it as Uuid if possible. Returns None otherwise.

source

fn as_date(&self) -> Option<Date>

If the Value is a String, represent it as Date if possible. Returns None otherwise.

source

fn as_time(&self) -> Option<Time>

If the Value is a String, represent it as Time if possible. Returns None otherwise.

source

fn as_datetime(&self) -> Option<DateTime>

If the Value is a String, represent it as DateTime if possible. Returns None otherwise.

source

fn as_duration(&self) -> Option<Duration>

If the Value is a String, represent it as Duration if possible. Returns None otherwise.

source

fn parse_bool(&self) -> Option<Result<bool, ParseBoolError>>

Parses the JSON value as bool.

source

fn parse_u8(&self) -> Option<Result<u8, ParseIntError>>

Parses the JSON value as u8.

source

fn parse_u16(&self) -> Option<Result<u16, ParseIntError>>

Parses the JSON value as u16.

source

fn parse_u32(&self) -> Option<Result<u32, ParseIntError>>

Parses the JSON value as u32.

source

fn parse_u64(&self) -> Option<Result<u64, ParseIntError>>

Parses the JSON value as u64.

source

fn parse_usize(&self) -> Option<Result<usize, ParseIntError>>

Parses the JSON value as usize.

source

fn parse_i8(&self) -> Option<Result<i8, ParseIntError>>

Parses the JSON value as i8.

source

fn parse_i16(&self) -> Option<Result<i16, ParseIntError>>

Parses the JSON value as i16.

source

fn parse_i32(&self) -> Option<Result<i32, ParseIntError>>

Parses the JSON value as i32.

source

fn parse_i64(&self) -> Option<Result<i64, ParseIntError>>

Parses the JSON value as i64.

source

fn parse_isize(&self) -> Option<Result<isize, ParseIntError>>

Parses the JSON value as isize.

source

fn parse_f32(&self) -> Option<Result<f32, ParseFloatError>>

Parses the JSON value as f32.

source

fn parse_f64(&self) -> Option<Result<f64, ParseFloatError>>

Parses the JSON value as f64.

source

fn parse_string(&self) -> Option<Cow<'_, str>>

Parses the JSON value as Cow<'_, str>. If the str is empty, it also returns None.

source

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.

source

fn parse_str_array(&self) -> Option<Vec<&str>>

Parses the JSON value as Vec<&str>. If the vec is empty, it also returns None.

source

fn parse_uuid(&self) -> Option<Result<Uuid, Error>>

Parses the JSON value as Uuid. If the Uuid is nil, it also returns None.

source

fn parse_decimal(&self) -> Option<Result<Decimal, Error>>

Parses the JSON value as Decimal.

source

fn parse_date(&self) -> Option<Result<Date, ParseError>>

Parses the JSON value as Date.

source

fn parse_time(&self) -> Option<Result<Time, ParseError>>

Parses the JSON value as Time.

source

fn parse_datetime(&self) -> Option<Result<DateTime, ParseError>>

Parses the JSON value as DateTime.

source

fn parse_duration(&self) -> Option<Result<Duration, ParseDurationError>>

Parses the JSON value as Duration.

source

fn to_string_pretty(&self) -> String

Returns a pretty-printed String of JSON.

source

fn to_string_unquoted(&self) -> String

Returns a unquoted String of JSON.

source

fn to_csv(&self, buffer: Vec<u8>) -> Result<Vec<u8>, Error>

Attempts to convert the JSON value to the CSV bytes.

source

fn to_jsonlines(&self, buffer: Vec<u8>) -> Result<Vec<u8>, Error>

Attempts to convert the JSON value to the JSON Lines bytes.

source

fn to_msgpack(&self, buffer: Vec<u8>) -> Result<Vec<u8>, Error>

Attempts to convert the JSON value to the MsgPack bytes.

source

fn into_map_array(self) -> Vec<Map>

Converts self into a map array.

source

fn into_map_opt(self) -> Option<Map>

Converts self into a map option.

Object Safety§

This trait is not object safe.

Implementors§