Parser for various Rust Strings.
Parsers for:
- Well Indent Strings (eg: dmidecode
output)
- KV pair Strings (eg: lscpu
output)
- Multiline KV pair strings (eg: systeminfo
output of windows)
- Dotted tree Strings (eg: sysctl
output)
toml
nparse = "0.0.4"
Indent
string into json```rust use 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.readtostring(&mut out).unwrap(); } let result = out.indenttojson(); println!("{:?}", result); } ```
K:V
string into json```rust use 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.readtostring(&mut out).unwrap(); } let result = out.kvstrto_json(); println!("{:?}", result); } ```
dotted
string into json (eg: parent.sub.sub: val
)```rust 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.readtostring(&mut out).unwrap(); } let result = out.dottedtreeto_json(); println!("{:?}", result); } ```
Test
bash
cargo t
Build Release
bash
cargo b --release
Parse dmidecode output to json
bash
cargo run --example dmidecode
Parse sysctl output to json
bash
cargo run --example sysctl
Parse lscpu to json
bash
cargo run --example lscpu
Parse windows systeminfo to json
bash
cargo run --example systeminfo