pub trait ToJson: Sealed {
// Required method
fn to_json_value(&self) -> Json;
// Provided method
fn to_json(&self) -> String { ... }
}Expand description
Conversion to the spec’s JSON form (camelCase keys, every key present, schema order).
Every output type also has to_json() as an inherent method; the trait is for generic code.
It is sealed: only the types of this crate implement it.
use trackparse::json::Json;
use trackparse::ToJson;
let track = trackparse::parse("Noisia - Stigma");
let value: Json = track.to_json_value();
assert_eq!(value.get("title").and_then(Json::as_str), Some("Stigma"));Required Methods§
Sourcefn to_json_value(&self) -> Json
fn to_json_value(&self) -> Json
The value as a JSON tree.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".