pub trait KVStrToJson {
// Required method
fn kv_str_to_json(&self) -> Result<Value, String>;
}Required Methods§
fn kv_str_to_json(&self) -> Result<Value, String>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl KVStrToJson for String
impl KVStrToJson for String
Source§fn kv_str_to_json(&self) -> Result<Value, String>
fn kv_str_to_json(&self) -> Result<Value, String>
Convert a Key Value String into a Json Document
§Example usage
use std::{fs::File, io::Read};
use nparse::KVStrToJson;
let path = "data/lscpu.txt";
let mut out = String::new();
{
let mut f = File::open(path).unwrap();
f.read_to_string(&mut out).unwrap();
}
let result = out.kv_str_to_json();
println!("{:#?}", result.unwrap());