Trait edm_core::extension::JsonObjectExt
source · pub trait JsonObjectExt {
Show 64 methods
// Required methods
fn get_bool(&self, key: &str) -> Option<bool>;
fn get_u8(&self, key: &str) -> Option<u8>;
fn get_u16(&self, key: &str) -> Option<u16>;
fn get_u32(&self, key: &str) -> Option<u32>;
fn get_u64(&self, key: &str) -> Option<u64>;
fn get_usize(&self, key: &str) -> Option<usize>;
fn get_i8(&self, key: &str) -> Option<i8>;
fn get_i16(&self, key: &str) -> Option<i16>;
fn get_i32(&self, key: &str) -> Option<i32>;
fn get_i64(&self, key: &str) -> Option<i64>;
fn get_isize(&self, key: &str) -> Option<isize>;
fn get_f32(&self, key: &str) -> Option<f32>;
fn get_f64(&self, key: &str) -> Option<f64>;
fn get_str(&self, key: &str) -> Option<&str>;
fn get_uuid(&self, key: &str) -> Option<Uuid>;
fn get_date(&self, key: &str) -> Option<Date>;
fn get_time(&self, key: &str) -> Option<Time>;
fn get_datetime(&self, key: &str) -> Option<DateTime>;
fn get_duration(&self, key: &str) -> Option<Duration>;
fn get_array(&self, key: &str) -> Option<&Vec<JsonValue>>;
fn get_u64_array(&self, key: &str) -> Option<Vec<u64>>;
fn get_i64_array(&self, key: &str) -> Option<Vec<i64>>;
fn get_f32_array(&self, key: &str) -> Option<Vec<f32>>;
fn get_f64_array(&self, key: &str) -> Option<Vec<f64>>;
fn get_str_array(&self, key: &str) -> Option<Vec<&str>>;
fn get_map_array(&self, key: &str) -> Option<Vec<&Map>>;
fn get_object(&self, key: &str) -> Option<&Map>;
fn parse_bool(&self, key: &str) -> Option<Result<bool, ParseBoolError>>;
fn parse_u8(&self, key: &str) -> Option<Result<u8, ParseIntError>>;
fn parse_u16(&self, key: &str) -> Option<Result<u16, ParseIntError>>;
fn parse_u32(&self, key: &str) -> Option<Result<u32, ParseIntError>>;
fn parse_u64(&self, key: &str) -> Option<Result<u64, ParseIntError>>;
fn parse_usize(&self, key: &str) -> Option<Result<usize, ParseIntError>>;
fn parse_i8(&self, key: &str) -> Option<Result<i8, ParseIntError>>;
fn parse_i16(&self, key: &str) -> Option<Result<i16, ParseIntError>>;
fn parse_i32(&self, key: &str) -> Option<Result<i32, ParseIntError>>;
fn parse_i64(&self, key: &str) -> Option<Result<i64, ParseIntError>>;
fn parse_isize(&self, key: &str) -> Option<Result<isize, ParseIntError>>;
fn parse_f32(&self, key: &str) -> Option<Result<f32, ParseFloatError>>;
fn parse_f64(&self, key: &str) -> Option<Result<f64, ParseFloatError>>;
fn parse_string(&self, key: &str) -> Option<Cow<'_, str>>;
fn parse_array<T: FromStr>(&self, key: &str) -> Option<Vec<T>>;
fn parse_str_array(&self, key: &str) -> Option<Vec<&str>>;
fn parse_enum_values(&self, key: &str) -> Option<Vec<JsonValue>>;
fn parse_object(&self, key: &str) -> Option<&Map>;
fn parse_uuid(&self, key: &str) -> Option<Result<Uuid, Error>>;
fn parse_decimal(&self, key: &str) -> Option<Result<Decimal, Error>>;
fn parse_date(&self, key: &str) -> Option<Result<Date, ParseError>>;
fn parse_time(&self, key: &str) -> Option<Result<Time, ParseError>>;
fn parse_datetime(&self, key: &str) -> Option<Result<DateTime, ParseError>>;
fn parse_duration(
&self,
key: &str
) -> Option<Result<Duration, ParseDurationError>>;
fn parse_url(&self, key: &str) -> Option<Result<Url, ParseError>>;
fn parse_ip(&self, key: &str) -> Option<Result<IpAddr, AddrParseError>>;
fn parse_ipv4(&self, key: &str) -> Option<Result<Ipv4Addr, AddrParseError>>;
fn parse_ipv6(&self, key: &str) -> Option<Result<Ipv6Addr, AddrParseError>>;
fn pointer(&self, pointer: &str) -> Option<&JsonValue>;
fn upsert(
&mut self,
key: impl Into<String>,
value: impl Into<JsonValue>
) -> Option<JsonValue>;
fn to_query_string(&self) -> String;
fn into_avro_record(self) -> Record;
fn from_entry(key: impl Into<String>, value: impl Into<JsonValue>) -> Self;
fn data_entry(value: Map) -> Self;
fn data_entries(values: Vec<Map>) -> Self;
fn data_item(value: impl Into<JsonValue>) -> Self;
fn data_items<T: Into<JsonValue>>(values: Vec<T>) -> Self;
}Expand description
Extension trait for Map.
Required Methods§
sourcefn get_bool(&self, key: &str) -> Option<bool>
fn get_bool(&self, key: &str) -> Option<bool>
Extracts the boolean value corresponding to the key.
sourcefn get_u8(&self, key: &str) -> Option<u8>
fn get_u8(&self, key: &str) -> Option<u8>
Extracts the integer value corresponding to the key
and represents it as u8 if possible.
sourcefn get_u16(&self, key: &str) -> Option<u16>
fn get_u16(&self, key: &str) -> Option<u16>
Extracts the integer value corresponding to the key
and represents it as u16 if possible.
sourcefn get_u32(&self, key: &str) -> Option<u32>
fn get_u32(&self, key: &str) -> Option<u32>
Extracts the integer value corresponding to the key
and represents it as u32 if possible.
sourcefn get_u64(&self, key: &str) -> Option<u64>
fn get_u64(&self, key: &str) -> Option<u64>
Extracts the integer value corresponding to the key
and represents it as u64 if possible.
sourcefn get_usize(&self, key: &str) -> Option<usize>
fn get_usize(&self, key: &str) -> Option<usize>
Extracts the integer value corresponding to the key
and represents it as usize if possible.
sourcefn get_i8(&self, key: &str) -> Option<i8>
fn get_i8(&self, key: &str) -> Option<i8>
Extracts the integer value corresponding to the key
and represents it as i8 if possible.
sourcefn get_i16(&self, key: &str) -> Option<i16>
fn get_i16(&self, key: &str) -> Option<i16>
Extracts the integer value corresponding to the key
and represents it as i16 if possible.
sourcefn get_i32(&self, key: &str) -> Option<i32>
fn get_i32(&self, key: &str) -> Option<i32>
Extracts the integer value corresponding to the key
and represents it as i32 if possible.
sourcefn get_i64(&self, key: &str) -> Option<i64>
fn get_i64(&self, key: &str) -> Option<i64>
Extracts the integer value corresponding to the key.
sourcefn get_isize(&self, key: &str) -> Option<isize>
fn get_isize(&self, key: &str) -> Option<isize>
Extracts the integer value corresponding to the key
and represents it as isize if possible.
sourcefn get_f32(&self, key: &str) -> Option<f32>
fn get_f32(&self, key: &str) -> Option<f32>
Extracts the float value corresponding to the key
and represents it as f32 if possible.
sourcefn get_uuid(&self, key: &str) -> Option<Uuid>
fn get_uuid(&self, key: &str) -> Option<Uuid>
Extracts the string corresponding to the key
and represents it as Uuid if possible.
sourcefn get_date(&self, key: &str) -> Option<Date>
fn get_date(&self, key: &str) -> Option<Date>
Extracts the string corresponding to the key
and represents it as Date if possible.
sourcefn get_time(&self, key: &str) -> Option<Time>
fn get_time(&self, key: &str) -> Option<Time>
Extracts the string corresponding to the key
and represents it as Time if possible.
sourcefn get_datetime(&self, key: &str) -> Option<DateTime>
fn get_datetime(&self, key: &str) -> Option<DateTime>
Extracts the string corresponding to the key
and represents it as DateTime if possible.
sourcefn get_duration(&self, key: &str) -> Option<Duration>
fn get_duration(&self, key: &str) -> Option<Duration>
Extracts the string corresponding to the key
and represents it as Duration if possible.
sourcefn get_array(&self, key: &str) -> Option<&Vec<JsonValue>>
fn get_array(&self, key: &str) -> Option<&Vec<JsonValue>>
Extracts the array value corresponding to the key.
sourcefn get_u64_array(&self, key: &str) -> Option<Vec<u64>>
fn get_u64_array(&self, key: &str) -> Option<Vec<u64>>
Extracts the array value corresponding to the key and parses it as Vec<u64>.
sourcefn get_i64_array(&self, key: &str) -> Option<Vec<i64>>
fn get_i64_array(&self, key: &str) -> Option<Vec<i64>>
Extracts the array value corresponding to the key and parses it as Vec<i64>.
sourcefn get_f32_array(&self, key: &str) -> Option<Vec<f32>>
fn get_f32_array(&self, key: &str) -> Option<Vec<f32>>
Extracts the array value corresponding to the key and parses it as Vec<f32>.
sourcefn get_f64_array(&self, key: &str) -> Option<Vec<f64>>
fn get_f64_array(&self, key: &str) -> Option<Vec<f64>>
Extracts the array value corresponding to the key and parses it as Vec<f64>.
sourcefn get_str_array(&self, key: &str) -> Option<Vec<&str>>
fn get_str_array(&self, key: &str) -> Option<Vec<&str>>
Extracts the array value corresponding to the key and parses it as Vec<&str>.
sourcefn get_map_array(&self, key: &str) -> Option<Vec<&Map>>
fn get_map_array(&self, key: &str) -> Option<Vec<&Map>>
Extracts the array value corresponding to the key and parses it as Vec<&Map>.
sourcefn get_object(&self, key: &str) -> Option<&Map>
fn get_object(&self, key: &str) -> Option<&Map>
Extracts the object value corresponding to the key.
sourcefn parse_bool(&self, key: &str) -> Option<Result<bool, ParseBoolError>>
fn parse_bool(&self, key: &str) -> Option<Result<bool, ParseBoolError>>
Extracts the value corresponding to the key and parses it as bool.
sourcefn parse_u8(&self, key: &str) -> Option<Result<u8, ParseIntError>>
fn parse_u8(&self, key: &str) -> Option<Result<u8, ParseIntError>>
Extracts the value corresponding to the key and parses it as u8.
sourcefn parse_u16(&self, key: &str) -> Option<Result<u16, ParseIntError>>
fn parse_u16(&self, key: &str) -> Option<Result<u16, ParseIntError>>
Extracts the value corresponding to the key and parses it as u16.
sourcefn parse_u32(&self, key: &str) -> Option<Result<u32, ParseIntError>>
fn parse_u32(&self, key: &str) -> Option<Result<u32, ParseIntError>>
Extracts the value corresponding to the key and parses it as u32.
sourcefn parse_u64(&self, key: &str) -> Option<Result<u64, ParseIntError>>
fn parse_u64(&self, key: &str) -> Option<Result<u64, ParseIntError>>
Extracts the value corresponding to the key and parses it as u64.
sourcefn parse_usize(&self, key: &str) -> Option<Result<usize, ParseIntError>>
fn parse_usize(&self, key: &str) -> Option<Result<usize, ParseIntError>>
Extracts the value corresponding to the key and parses it as usize.
sourcefn parse_i8(&self, key: &str) -> Option<Result<i8, ParseIntError>>
fn parse_i8(&self, key: &str) -> Option<Result<i8, ParseIntError>>
Extracts the value corresponding to the key and parses it as i8.
sourcefn parse_i16(&self, key: &str) -> Option<Result<i16, ParseIntError>>
fn parse_i16(&self, key: &str) -> Option<Result<i16, ParseIntError>>
Extracts the value corresponding to the key and parses it as i16.
sourcefn parse_i32(&self, key: &str) -> Option<Result<i32, ParseIntError>>
fn parse_i32(&self, key: &str) -> Option<Result<i32, ParseIntError>>
Extracts the value corresponding to the key and parses it as i32.
sourcefn parse_i64(&self, key: &str) -> Option<Result<i64, ParseIntError>>
fn parse_i64(&self, key: &str) -> Option<Result<i64, ParseIntError>>
Extracts the value corresponding to the key and parses it as i64.
sourcefn parse_isize(&self, key: &str) -> Option<Result<isize, ParseIntError>>
fn parse_isize(&self, key: &str) -> Option<Result<isize, ParseIntError>>
Extracts the value corresponding to the key and parses it as isize.
sourcefn parse_f32(&self, key: &str) -> Option<Result<f32, ParseFloatError>>
fn parse_f32(&self, key: &str) -> Option<Result<f32, ParseFloatError>>
Extracts the value corresponding to the key and parses it as f32.
sourcefn parse_f64(&self, key: &str) -> Option<Result<f64, ParseFloatError>>
fn parse_f64(&self, key: &str) -> Option<Result<f64, ParseFloatError>>
Extracts the value corresponding to the key and parses it as f64.
sourcefn parse_string(&self, key: &str) -> Option<Cow<'_, str>>
fn parse_string(&self, key: &str) -> Option<Cow<'_, str>>
Extracts the value corresponding to the key and parses it as Cow<'_, str>.
If the str is empty, it also returns None.
sourcefn parse_array<T: FromStr>(&self, key: &str) -> Option<Vec<T>>
fn parse_array<T: FromStr>(&self, key: &str) -> Option<Vec<T>>
Extracts the array value corresponding to the key and parses it as Vec<T>.
If the vec is empty, it also returns None.
sourcefn parse_str_array(&self, key: &str) -> Option<Vec<&str>>
fn parse_str_array(&self, key: &str) -> Option<Vec<&str>>
Extracts the array value corresponding to the key and parses it as Vec<&str>.
If the vec is empty, it also returns None.
sourcefn parse_enum_values(&self, key: &str) -> Option<Vec<JsonValue>>
fn parse_enum_values(&self, key: &str) -> Option<Vec<JsonValue>>
Extracts the enum values corresponding to the key
and parses it as Vec<i64> or Vec<String>.
If the vec is empty, it also returns None.
sourcefn parse_object(&self, key: &str) -> Option<&Map>
fn parse_object(&self, key: &str) -> Option<&Map>
Extracts the object value corresponding to the key and parses it as Map.
If the map is empty, it also returns None.
sourcefn parse_uuid(&self, key: &str) -> Option<Result<Uuid, Error>>
fn parse_uuid(&self, key: &str) -> Option<Result<Uuid, Error>>
Extracts the string corresponding to the key and parses it as Uuid.
If the Uuid is nil, it also returns None.
sourcefn parse_decimal(&self, key: &str) -> Option<Result<Decimal, Error>>
fn parse_decimal(&self, key: &str) -> Option<Result<Decimal, Error>>
Extracts the string corresponding to the key and parses it as Decimal.
sourcefn parse_date(&self, key: &str) -> Option<Result<Date, ParseError>>
fn parse_date(&self, key: &str) -> Option<Result<Date, ParseError>>
Extracts the string corresponding to the key and parses it as Date.
sourcefn parse_time(&self, key: &str) -> Option<Result<Time, ParseError>>
fn parse_time(&self, key: &str) -> Option<Result<Time, ParseError>>
Extracts the string corresponding to the key and parses it as Time.
sourcefn parse_datetime(&self, key: &str) -> Option<Result<DateTime, ParseError>>
fn parse_datetime(&self, key: &str) -> Option<Result<DateTime, ParseError>>
Extracts the string corresponding to the key and parses it as DateTime.
sourcefn parse_duration(
&self,
key: &str
) -> Option<Result<Duration, ParseDurationError>>
fn parse_duration( &self, key: &str ) -> Option<Result<Duration, ParseDurationError>>
Extracts the string corresponding to the key and parses it as Duration.
sourcefn parse_url(&self, key: &str) -> Option<Result<Url, ParseError>>
fn parse_url(&self, key: &str) -> Option<Result<Url, ParseError>>
Extracts the string corresponding to the key and parses it as Url.
sourcefn parse_ip(&self, key: &str) -> Option<Result<IpAddr, AddrParseError>>
fn parse_ip(&self, key: &str) -> Option<Result<IpAddr, AddrParseError>>
Extracts the string corresponding to the key and parses it as IpAddr.
sourcefn parse_ipv4(&self, key: &str) -> Option<Result<Ipv4Addr, AddrParseError>>
fn parse_ipv4(&self, key: &str) -> Option<Result<Ipv4Addr, AddrParseError>>
Extracts the string corresponding to the key and parses it as Ipv4Addr.
sourcefn parse_ipv6(&self, key: &str) -> Option<Result<Ipv6Addr, AddrParseError>>
fn parse_ipv6(&self, key: &str) -> Option<Result<Ipv6Addr, AddrParseError>>
Extracts the string corresponding to the key and parses it as Ipv6Addr.
sourcefn pointer(&self, pointer: &str) -> Option<&JsonValue>
fn pointer(&self, pointer: &str) -> Option<&JsonValue>
Looks up a value by a JSON Pointer.
A Pointer is a Unicode string with the reference tokens separated by /.
Inside tokens / is replaced by ~1 and ~ is replaced by ~0.
The addressed value is returned and if there is no such value None is returned.
sourcefn upsert(
&mut self,
key: impl Into<String>,
value: impl Into<JsonValue>
) -> Option<JsonValue>
fn upsert( &mut self, key: impl Into<String>, value: impl Into<JsonValue> ) -> Option<JsonValue>
Inserts or updates a pair into the map.
If the map did have this key present, the value is updated and the old value is returned,
otherwise None is returned.
sourcefn to_query_string(&self) -> String
fn to_query_string(&self) -> String
Serializes the map into a query string.
sourcefn into_avro_record(self) -> Record
fn into_avro_record(self) -> Record
Consumes self and constructs an Avro record value.
sourcefn from_entry(key: impl Into<String>, value: impl Into<JsonValue>) -> Self
fn from_entry(key: impl Into<String>, value: impl Into<JsonValue>) -> Self
Creates a new instance with the entry.
sourcefn data_entry(value: Map) -> Self
fn data_entry(value: Map) -> Self
Creates a new instance with a single key entry.
sourcefn data_entries(values: Vec<Map>) -> Self
fn data_entries(values: Vec<Map>) -> Self
Creates a new instance with the entries.
sourcefn data_item(value: impl Into<JsonValue>) -> Self
fn data_item(value: impl Into<JsonValue>) -> Self
Creates a new instance with a single key item.
sourcefn data_items<T: Into<JsonValue>>(values: Vec<T>) -> Self
fn data_items<T: Into<JsonValue>>(values: Vec<T>) -> Self
Creates a new instance with the items.