JSON
JSON format (application/json).
{
"message": "hello, world",
"person": {
"name": "Bob Smith",
"age": 42
}
}import "./test.json"; // uses "json" format
#[main]
fn main() {
assert_eq(self.message, "hello, world");
assert_eq(self.person.name, "Bob Smith");
assert_eq(self.person.age, 42);
const json = stringify("json", self); // string export (fields only)
assert_eq(json, '{"message":"hello, world","person":{"name":"Bob Smith","age":42}}');
}Last updated