Skip to main content

print_json

Function print_json 

Source
pub fn print_json<T: Serialize>(value: &T, fields: Option<&[String]>)
Expand description

Print a serializable value as pretty JSON to stdout.

If fields is Some, only the specified top-level fields are included in the output. If fields is None, the entire value is printed.

§Panics

Panics if the value cannot be serialized to JSON (this should never happen for well-formed data).

§Examples

use gor::output::print_json;
use serde_json::json;

let data = json!({"name": "hello-world", "stars": 42});
print_json(&data, None::<&[String]>);