cj
colored_json
cargo install colored_json
cj

colored_json

Generating colored JSON in Rust

by Jens Reimann

2.1.0 (see all)License:EPL-2.0
cargo install colored_json
Readme

Screenshot

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"
    }
    "#.to_colored_json_auto()?
    );
    Ok(())
}

Or directly write it out:

extern crate serde_json;
extern crate colored_json;
use serde_json::{from_str, Value};
use std::io::stdout;
use std::io::Write;

pub fn main() -> ::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();
    {
        let mut out = out.lock();
        colored_json::write_colored_json(&value, &mut out)?;
        out.flush()?;
    }
    Ok(())
}

GitHub Stars

16

LAST COMMIT

3yrs ago

MAINTAINERS

2

CONTRIBUTORS

5

OPEN ISSUES

0

OPEN PRs

0
VersionTagPublished
2.1.0
3yrs ago
2.0.0
3yrs ago
1.0.0
4yrs ago
0.6.2
4yrs ago
No alternatives found
No tutorials found
Add a tutorial