Colored JSON output for Rust ci docs.rs Crates.io

Also see: * https: https://crates.io/crates/colored_json

Screenshot

Using

Add it to your project:

~~~toml [dependencies] colored_json = "3" ~~~

And then color your JSON output:

~~~rust extern crate colored_json;

use colored_json::prelude::*;

fn main() -> ::std::result::Result<(), Box<::std::error::Error>> { println!( "{}", r#" { "array": [ "ele1", "ele2" ], "float": 3.1415926, "integer": 4398798674962568, "string": "string" } "#.tocoloredjson_auto()? ); Ok(()) } ~~~

Or directly write it out:

~~~rust extern crate serdejson; extern crate coloredjson; use serdejson::{fromstr, Value}; use std::io::stdout; use std::io::Write;

pub fn main() -> ::std::result::Result<(), Box<::std::error::Error>> { let value: Value = fromstr(r#" { "array": [ "ele1", "ele2" ], "float": 3.1415926, "integer": 4398798674962568, "string": "string" } "#)?; let out = stdout(); { let mut out = out.lock(); coloredjson::writecoloredjson(&value, &mut out)?; out.flush()?; } Ok(()) } ~~~