jstrict 0.14.0

Strict RFC 8259 / ECMA-404 JSON parser with source code mapping
Documentation
//! This example shows how to serialize and deserialize `jstrict::Value`
//! using the `serde` crate. This will not allow you to attach metadata to each
//! value fragment (the `M` type will be unit `()`).
use jstrict::Print;

#[derive(Debug, PartialEq, serde::Serialize, serde::Deserialize)]
struct MyType {
	foo: String,
	bar: Vec<u32>,
}

fn main() {
	// Instantiate our type.
	let a = MyType {
		foo: "Hello World!".to_string(),
		bar: vec![1, 2, 3],
	};

	// Serialize `a` into a JSON value.
	let json = jstrict::to_value(&a).expect("serialization failed");

	// Print the value.
	println!("{}", json.pretty_print());

	// Deserialize JSON back into `MyType`.
	let b: MyType = jstrict::from_value(json).expect("deserialization failed");

	// The round-trip should not change the actual data.
	assert_eq!(a, b)
}