ASON is the next evolution of data formats, enhancing JSON with strong data typing and variant types. Its intuitive syntax, inspired by Rust, ensures easy readability and maintenance, making it ideal for configuration files and data storage. Transitioning from JSON is seamless, allowing developers to embrace the future of data effortlessly.
ASON is an innovative data format that has evolved from JSON, bringing forth strong data typing and support for variant types. It is designed for excellent readability and maintainability, making it a top choice for configuration files, data transfer, and data storage.
Key Features
- JSON Compatibility: ASON seamlessly integrates with base JSON and JSON5 syntax, ensuring a smooth transition for users familiar with JSON.
- Consistent Syntax: Its syntax closely resembles Rust, supporting comments, omitting double quotes for structure field names, and allowing trailing commas in lists, enhancing both familiarity and writing ease.
- Strong Data Typing: ASON supports explicit typing for numbers (e.g.,
u8
,i32
,f32
,f64
), as well as hexadecimal and binary representations. New types likeDateTime
,Tuple
,ByteData
, andChar
enrich the type system for rigorous data representation. - Native Variant Support: The format includes native support for variant data types, thus eliminating the error-prone
null
value and enabling seamless serialization of complex data structures.
Example Usage
Here’s a brief example showcasing ASON’s capabilities:
{
string: "Hello World 🍀"
raw_string: r"[a-z]+\d+"
integer_number: 123
floating_point_number: 3.14
number_with_explicit_type: 255_u8
boolean: true
datetime: d"2023-03-24 12:30:00+08:00"
bytedata: h"68 65 6c 6c 6f"
list: [1, 2, 3]
tuple: (1, "foo", true)
object: {
id: 123
name: "Alice"
}
map: {
123: "Alice"
456: "Bob"
}
variant: Option::None
variant_with_value: Option::Some(123)
tuple_style_variant: Color::RGB(255, 127, 63)
object_style_variant: Shape::Rect{
width: 200
height: 100
}
}
Comparison with Other Formats
Compared to JSON
ASON enhances JSON by:
- Allowing trailing commas and omitted double quotes for object keys.
- Introducing various numeric data types.
- Supporting long, raw, and auto-trimmed strings, as well as comments.
- Removing
null
to provide a more robust variant implementation.
Compared to YAML and TOML
While YAML may introduce indentation complexities and TOML struggles with hierarchical representation, ASON stands out with consistency and simplicity across datasets of any size, making it easier to maintain.
Filename Extension
Files using ASON format should have the .ason
extension, such as sample.ason
or package.ason
.
Libraries and APIs
The Rust ASON library supports serialization and deserialization through a simple API based on serde
, with low-level access available through AST (Abstract Syntax Tree) operations. It is generally recommended to utilize the serde
API for straightforward applications.
Serialization Example
To demonstrate serialization:
let text = "..."; // ASON text here
let package = from_str::<Package>(text).unwrap();
AST Operations
To parse an ASON text and access its AST:
let node = parse_from_str(text).unwrap();
Conclusion
With its strong data typing, readability, and added features, ASON provides a compelling alternative to traditional data formats such as JSON, YAML, and TOML. Experience robust data representation in your applications with ASON.