Skip to content

Repository files navigation

Colored JSON output for Rust cidocs.rsCrates.io

Screenshot

Using

Add it to your project:

[dependencies]
colored_json = "4"

And then color your JSON output:

use colored_json::prelude::*;fnmain() -> ::std::result::Result<(),Box<::std::error::Error>>{println!("{}",r#" { "array": [ "ele1", "ele2" ], "float": 3.1415926, "integer": 4398798674962568, "string": "string" } "#.to_colored_json_auto()?
);Ok(())}

Or directly write it out:

use serde_json::{from_str,Value};use std::io::stdout;use std::io::Write;pubfnmain() -> ::std::result::Result<(),Box<::std::error::Error>>{let value:Value = from_str(r#" { "array": [ "ele1", "ele2" ], "float": 3.1415926, "integer": 4398798674962568, "string": "string" } "#)?;let out = stdout();{letmut out = out.lock();
colored_json::write_colored_json(&value,&mut out)?;
out.flush()?;}Ok(())}

About

Generating colored JSON in Rust

Topics

Resources

Stars

33 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages