ison-rs
A Rust implementation of the ISON (Interchange Simple Object Notation) parser.
ISON is a minimal, LLM-friendly data serialization format optimized for:
- Graph databases
- Multi-agent systems
- RAG pipelines
- Token-efficient AI/ML workflows
Features
- Zero-copy parsing where possible
- Full ISON Support: Tables, objects, references, type annotations
- ISONL Streaming: Line-based format for large datasets
- Serde Integration: Optional JSON export via serde
- No unsafe code: Safe Rust implementation
Installation
Add to your Cargo.toml:
[]
= "1.0"
# With serde/JSON support (default)
= { = "1.0", = ["serde"] }
# Without serde (smaller binary)
= { = "1.0", = false }
Quick Start
use ;
API Reference
Parsing
use ;
// Parse from string
let doc = parse?;
let doc = loads?; // Alias
// Parse ISONL
let doc = loads_isonl?;
Serialization
use ;
// To ISON string
let ison = dumps; // With column alignment
let ison = dumps; // Without alignment
// To ISONL
let isonl = dumps_isonl;
// To JSON (requires serde feature)
let json = doc.to_json; // Pretty-printed
let json = doc.to_json; // Compact
Document Access
let doc = parse?;
// Check if block exists
if doc.has
Value Types
use Value;
// Value is an enum
match value
// Type checking
value.is_null;
value.is_bool;
value.is_int;
value.is_float;
value.is_string;
value.is_reference;
// Value extraction (returns Option)
let b: = value.as_bool;
let i: = value.as_int;
let f: = value.as_float;
let s: = value.as_str;
let r: = value.as_reference;
References
use Reference;
// Simple reference :42
let ref1 = new;
ref1.to_ison; // ":42"
// Namespaced reference :user:101
let ref2 = with_type;
ref2.get_namespace; // Some("user")
ref2.is_relationship; // false
// Relationship reference :MEMBER_OF:10
let ref3 = with_type;
ref3.is_relationship; // true
ref3.relationship_type; // Some("MEMBER_OF")
Creating Documents Programmatically
use ;
use HashMap;
let mut doc = new;
let mut block = new;
block.fields = vec!;
block.field_info = vec!;
let mut row = new;
row.insert;
row.insert;
block.rows.push;
doc.blocks.push;
let ison = dumps;
Field Info
// Access type annotations
for fi in &block.field_info
// Query field types
let field_type = block.get_field_type; // Option<&str>
let computed = block.get_computed_fields; // Vec<&str>
ISONL Format
ISONL is a line-based streaming format where each line is self-contained:
table.users|id name email|1 Alice alice@example.com
table.users|id name email|2 Bob bob@example.com
use ;
// Convert between formats
let isonl = ison_to_isonl?;
let ison = isonl_to_ison?;
Error Handling
use ;
match parse
ISON Format Quick Reference
# Comment
table.users # Block header: kind.name
id:int name:string active:bool # Field definitions with optional types
1 Alice true # Data rows
2 "Bob Smith" false # Quoted strings for spaces
3 ~ null # null values (~ or null)
table.orders
id user_id product
1 :1 Widget # :1 = reference to id 1
2 :user:42 Gadget # :user:42 = namespaced reference
3 :MEMBER_OF:10 Thing # :MEMBER_OF:10 = relationship reference
object.config # Single-row object block
key value
debug true
Total 100 # Summary row
Test Results
All tests passing:
running 5 tests
test tests::test_isonl ... ok
test tests::test_parse_references ... ok
test tests::test_parse_simple_table ... ok
test tests::test_roundtrip ... ok
test tests::test_type_inference ... ok
test result: ok. 5 passed; 0 failed; 0 ignored
Doc-tests ison_rs
test result: ok. 1 passed; 0 failed; 1 ignored
Run tests with:
Links
License
MIT License