mysql_row_to_json

Function mysql_row_to_json 

Source
pub fn mysql_row_to_json(row: &Row, column_names: &[String]) -> Result<Value>
Expand description

Convert a MySQL Row to a JSONB-compatible JSON object

Converts all columns in the row to a JSON object with column names as keys.

§Arguments

  • row - MySQL Row to convert
  • column_names - Names of columns in the row (from table schema)

§Returns

JSON object with all column values

§Examples

let column_names = vec!["id".to_string(), "name".to_string()];
let json_obj = mysql_row_to_json(&row, &column_names)?;