Parser for various Rust Strings.
Parsers for:
dmidecode
output)lscpu
output)systeminfo
output of windows)sysctl
output)nparse = "0.0.10"
Indent
string into jsonuse std::{fs::File, io::Read};
use nparse::*;
fn main () {
let path = "data/dmidecode.txt";
let mut out = String::new();
{
let mut f = File::open(path).unwrap();
f.read_to_string(&mut out).unwrap();
}
let result = out.indent_to_json();
println!("{:?}", result);
}
K:V
string into jsonuse std::{fs::File, io::Read};
use nparse::*;
fn main () {
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);
}
K=V
string into jsonuse std::{fs::File, io::Read};
use nparse::*;
fn main () {
let path = "data/os-release.txt";
let mut out = String::new();
{
let mut f = File::open(path).unwrap();
f.read_to_string(&mut out).unwrap();
}
let result = out.kev_str_to_json();
println!("{:?}", result);
}
dotted
string into json (eg: parent.sub.sub: val
)use std::{fs::File, io::Read};
use nparse::*;
fn main () {
let path = "data/sysctl.txt";
let mut out = String::new();
{
let mut f = File::open(path).unwrap();
f.read_to_string(&mut out).unwrap();
}
let result = out.dotted_tree_to_json();
println!("{:?}", result);
}
Test
cargo t
Build Release
cargo b --release
Parse dmidecode output to json
cargo run --example dmidecode
Parse sysctl output to json
cargo run --example sysctl
Parse lscpu to json
cargo run --example lscpu
Parse windows systeminfo to json
cargo run --example systeminfo