CKS Data Format

CKS is a language-neutral data serialization tool.

Learn More

Example

Let’s say we wanted to store a simple list of students. Here’s a possible type definition (file: “students.tcks”):

def Students = List(Student)

def Student = {
  Name: String
  Age: Nat16      // unsigned 16-bit integer
  Sex: Sex        // "Male" or "Female" (defined below)
}

def Sex = < Male, Female >   // a "variant" type

A sample value, using the text format (file: “students.cks”):

[        // square brackets for lists
  {        // braces for records
    Name = "Scooby Doo"
    Age = 55
    Sex = Male
  }
  {
    Name = "Wilma Flintstone"
    Age = 4012
    Sex = Female
  }
]

Using it in your program.

We currently support Java, C#, and Haskell. Running the “cks” tool on the type file will generate helper code in the specified language.

Using the “cks” tool to convert your data.

The “cks” tool can convert between the text and binary formats. Usage:

> cks convert <type-file> <type-name> <input> <output>

For example, to convert the example value from text to binary, run:

> cks convert students.tcks Students \
      text:students.cks binary:students.bin

The binary version looks roughly like this:

 2 10 "Scooby Doo" 0x0037 0
   16 "Wilma Flintstone" 0x0fac 1