Skip to main content

jsonb_to_string

Function jsonb_to_string 

Source
pub fn jsonb_to_string(val: &[u8]) -> Result<String>
Expand description

Converts a json type value to string

The binary jsonb is serialized directly with serde_json, so object keys and string values are escaped by serde_json. RawJsonb::to_string() is avoided, since it falls back to the lossy raw bytes when serialization fails.

Some write paths (e.g. COPY FROM files, or a JSON parameter bound as text through the MySQL protocol) store JSON text in place of binary jsonb. Bytes that fail to serialize are parsed as text with the extended parser, as jsonb::from_slice does.