Data Modelling With ftd
ftd
is an alternative to XML/JSON for storing data.
Optimized For Human Readability
ftd
is designed for humans to write data. It tries to be a minimal as possible, intuitive and readable, no quote character for strings, avoid indentation etc.
ftd file containing data
-- record person: caption name: string location: optional body bio: -- person amitu: Amit Upadhyay location: Banglore, India Amit is the founder and CEO of FifthTry.
Consider this example. We have described our data, person
, and notice we have type for each field. Notice also our types caption
, which like “heading of the data”, body
, which lets people write multiline strings without worrying about quoting or indentation etc.
Read our ftd::p1
grammar guide to understand the low level grammer better.
Rich Data Modelling
It has support for typed variables, records
(struct
in other languages), or-type
(enum
in Rust, also called “algebraic data type”) and lists.
FTD files can be validated to confirm to strict type or not, and this can be used by editors to assist humans write correct ftd files.
Reading FTD Files
Programs can read ftd files:
#[derive(serde::Deserialize)] struct Employee { name: String, location: String, bio: Option<String> } let doc = ftd::p2::Document::from("some/id", source, lib)?; let amitu: Employee = doc.get("amitu")?;
Read more about it in “reading data” guide.
Better Organization Of Data
ftd
also supports referring to other ftd
files, so one can describe the schema or data in one file and refer it from other files.