Struct tidb_query_datatype::codec::mysql::json::Json [−][src]
Json implements type json used in tikv by Binary Json.
The Binary Json format from MySQL
5.7 is in the following link:
(https://github.com/mysql/mysql-server/blob/5.7/sql/json_binary.h#L52)
The only difference is that we use large object
or large array
for
the small corresponding ones. That means in our implementation there
is no difference between small object
and big object
, so does array
.
Fields
type_code: JsonType
value: Vec<u8>
The binary encoded json data in bytes
Implementations
impl Json
[src][−]
pub fn merge(bjs: Vec<JsonRef<'_>>) -> Result<Json>
[src][−]
merge
is the implementation for JSON_MERGE in mysql
https://dev.mysql.com/doc/refman/5.7/en/json-modification-functions.html#function_json-merge
The merge rules are listed as following:
- adjacent arrays are merged to a single array;
- adjacent object are merged to a single object;
- a scalar value is autowrapped as an array before merge;
- an adjacent array and object are merged by autowrapping the object as an array.
See MergeBinary()
in TiDB json/binary_function.go
impl Json
[src][−]
pub fn new(tp: JsonType, value: Vec<u8>) -> Self
[src][−]
Creates a new JSON from the type and encoded bytes
pub fn get_type(&self) -> JsonType
[src][−]
Returns the JSON type
pub fn from_string(s: String) -> Result<Self>
[src][−]
Creates a string
JSON from a String
pub fn from_str_val(s: &str) -> Result<Self>
[src][−]
Creates a string
JSON from a &str
pub fn from_bool(b: bool) -> Result<Self>
[src][−]
Creates a literal
JSON from a bool
pub fn from_u64(v: u64) -> Result<Self>
[src][−]
Creates a number
JSON from a u64
pub fn from_f64(v: f64) -> Result<Self>
[src][−]
Creates a number
JSON from a f64
pub fn from_i64(v: i64) -> Result<Self>
[src][−]
Creates a number
JSON from an i64
pub fn from_ref_array(array: Vec<JsonRef<'_>>) -> Result<Self>
[src][−]
Creates a array
JSON from a collection of JsonRef
pub fn from_array(array: Vec<Json>) -> Result<Self>
[src][−]
Creates a array
JSON from a collection of Json
pub fn from_kv_pairs(entries: Vec<(&[u8], JsonRef<'_>)>) -> Result<Self>
[src][−]
Creates a object
JSON from key-value pairs
pub fn from_object(map: BTreeMap<String, Json>) -> Result<Self>
[src][−]
Creates a object
JSON from key-value pairs in BTreeMap
pub fn none() -> Result<Self>
[src][−]
Creates a null
JSON
pub fn as_ref(&self) -> JsonRef<'_>
[src][−]
Returns a JsonRef
points to the starting of encoded bytes
Trait Implementations
impl AsMySQLBool for Json
[src][+]
impl ChunkedVec<Json> for ChunkedVecJson
[src][+]
impl Clone for Json
[src][+]
impl ConvertTo<Decimal> for Json
[src][+]
impl ConvertTo<Json> for i64
[src][+]
impl ConvertTo<Json> for f64
[src][+]
impl ConvertTo<Json> for Real
[src][+]
impl ConvertTo<Json> for Decimal
[src][+]
impl ConvertTo<Json> for Time
[src][+]
impl ConvertTo<Json> for Duration
[src][+]
impl ConvertTo<f64> for Json
[src][+]
impl Debug for Json
[src][+]
impl<'de> Deserialize<'de> for Json
[src][+]
impl Display for Json
[src][+]
impl Eq for Json
[src]
impl EvaluableRet for Json
[src][+]
impl From<Json> for ScalarValue
[src][+]
impl From<Json> for Datum
[src][+]
impl FromStr for Json
[src][+]
impl Ord for Json
[src][+]
impl PartialEq<Json> for Json
[src][+]
impl PartialOrd<Json> for Json
[src][+]
impl<'a> RawDatumDecoder<Json> for &'a [u8]
[src][+]
impl ToInt for Json
[src][+]
impl ToString for Json
[src][+]
impl VectorValueExt<Json> for VectorValue
[src][+]
Auto Trait Implementations
impl RefUnwindSafe for Json
impl Send for Json
impl Sync for Json
impl Unpin for Json
impl UnwindSafe for Json
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src][+]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<V, W> ConvertFrom<W> for V where
W: ConvertTo<V>,
[src][+]
W: ConvertTo<V>,
impl<T> ConvertTo<NotNan<f64>> for T where
T: ConvertTo<f64> + EvaluableRet,
[src][+]
T: ConvertTo<f64> + EvaluableRet,
impl<T> ConvertTo<String> for T where
T: ToString + EvaluableRet,
[src][+]
T: ToString + EvaluableRet,
impl<T> ConvertTo<Vec<u8, Global>> for T where
T: ToString + EvaluableRet,
[src][+]
T: ToString + EvaluableRet,
impl<T> ConvertTo<i64> for T where
T: ToInt,
[src][+]
T: ToInt,
impl<T> ConvertTo<u64> for T where
T: ToInt,
[src][+]
T: ToInt,
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src][+]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
impl<T> From<T> for T
[src][+]
impl<T> Instrument for T
[src][+]
impl<T, U> Into<U> for T where
U: From<T>,
[src][+]
U: From<T>,
impl<T> Pointable for T
[src][+]
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T> Sealed<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> SendSyncUnwindSafe for T where
T: Send + Sync + UnwindSafe + ?Sized,
[src]
T: Send + Sync + UnwindSafe + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src][+]
T: Clone,
impl<T> ToString for T where
T: Display + ?Sized,
[src][+]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src][+]
V: MultiLane<T>,