mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-26 03:59:55 +00:00
15 lines
282 B
Rust
15 lines
282 B
Rust
pub use serde_json::*;
|
|
|
|
pub trait ToJson {
|
|
fn to_json(&self) -> Value;
|
|
}
|
|
|
|
impl<T: ToJson> ToJson for Option<T> {
|
|
fn to_json(&self) -> Value {
|
|
if let Some(value) = self.as_ref() {
|
|
value.to_json()
|
|
} else {
|
|
json!(null)
|
|
}
|
|
}
|
|
}
|