nbt-sniffer 0.2.0

A command-line tool designed to scan Minecraft Java Edition world data.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use serde_json::Value as JsonValue;

/// Helper function to serialize a JsonValue to a string (pretty or compact)
/// and print it to stdout, or print an error to stderr.
pub fn print_json_output(json_value: &JsonValue, pretty: bool) {
    let result = if pretty {
        serde_json::to_string_pretty(json_value)
    } else {
        serde_json::to_string(json_value)
    };

    match result {
        Ok(s) => println!("{s}"),
        Err(e) => {
            eprintln!("Error serializing to JSON: {e}");
        }
    }
}