jstrict 0.16.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;
use std::error::Error;

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

fn main() -> Result<(), Box<dyn Error>> {
	// 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)?;

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

	// Deserialize JSON back into `MyType`.
	let b: MyType = jstrict::from_value(json)?;

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