Add a sql::Value::into_json() method (#1963)

This commit is contained in:
Rushmore Mushambi 2023-05-10 14:12:47 +02:00 committed by GitHub
parent 1140c36942
commit f1ef3bfd21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -53,6 +53,7 @@ use nom::multi::separated_list0;
use nom::multi::separated_list1;
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
use serde_json::Value as Json;
use std::cmp::Ordering;
use std::collections::BTreeMap;
use std::collections::HashMap;
@ -1020,6 +1021,14 @@ impl Value {
}
}
/// Converts a `surrealdb::sq::Value` into a `serde_json::Value`
///
/// This converts certain types like `Thing` into their simpler formats
/// instead of the format used internally by SurrealDB.
pub fn into_json(self) -> Json {
self.into()
}
// -----------------------------------
// Simple conversion of value
// -----------------------------------