1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! # TOON-LD
//!
//! **Token-Oriented Object Notation for Linked Data** — A compact RDF serialization format
//! that achieves 40-60% token reduction compared to JSON-LD.
//!
//! This crate provides high-level conversion functions between JSON-LD and TOON-LD formats.
//! TOON-LD extends TOON in the same way that JSON-LD extends JSON: every valid TOON-LD
//! document is also a valid TOON document.
//!
//! ## Quick Start
//!
//! ```rust
//! use toon_ld::{encode, decode};
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Convert JSON-LD to TOON-LD
//! let json_ld = r#"{
//! "@context": {"foaf": "http://xmlns.com/foaf/0.1/"},
//! "foaf:name": "Alice"
//! }"#;
//!
//! let toon = encode(json_ld)?;
//! println!("TOON-LD:\n{}", toon);
//!
//! // Convert back to JSON-LD
//! let back_to_json = decode(&toon)?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Tabular Arrays
//!
//! TOON-LD's key feature is efficient serialization of arrays of objects:
//!
//! ```rust
//! use toon_ld::encode;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let json_ld = r#"{
//! "@context": {"foaf": "http://xmlns.com/foaf/0.1/"},
//! "@graph": [
//! {"@id": "ex:1", "foaf:name": "Alice", "foaf:age": 30},
//! {"@id": "ex:2", "foaf:name": "Bob", "foaf:age": 25}
//! ]
//! }"#;
//!
//! let toon = encode(json_ld)?;
//! // Output uses tabular format with shared headers:
//! // @graph[2]{@id,foaf:age,foaf:name}:
//! // ex:1, 30, Alice
//! // ex:2, 25, Bob
//! # Ok(())
//! # }
//! ```
//!
//! ## Features
//!
//! - **40-60% token reduction** compared to JSON-LD
//! - **Full JSON-LD compatibility** with round-trip conversion
//! - **Tabular arrays** for efficient serialization of uniform data
//! - **Context support** for URI compaction
//! - **Value nodes** with language tags and datatypes
//! - **Optimized parsing** with automatic tabular array detection
// Re-export everything from toon-core
pub use *;
// Re-export commonly used types from dependencies
pub use Value;