Ion (serialization format)

Ion
Filename extension
.ion
Internet media typeapplication/ion
Developed byAmazon
Type of formatData interchange
Websiteamzn.github.io/ion-docs/

Ion is a data serialization language developed by Amazon. It may be represented by either a human-readable text form or a compact binary form. The text form is a superset of JSON; thus, any valid JSON document is also a valid Ion document.

Data types

As a superset of JSON, Ion includes the following data types

The nebulous JSON 'number' type is strictly defined in Ion to be one of

Ion adds these types:

Each Ion type supports a null variant, indicating a lack of value while maintaining a strict type (e.g., null.int, null.struct).

The Ion format permits attaching one or more annotations (i.e. a list of symbols) to any value. Such annotations may be used as metadata for otherwise opaque data (such as a blob).

Implementations

Examples

Sample document

Features seen in JavaScript and JSON5:

// Comments are allowed using the double forward slash 
{
  key: "value",   // key here is a symbol, it can also be a string as in JSON
  nums: 1_000_000, // equivalent to 1000000, use of underscores with numbers is more readable
  "A float": 31415e-4,  // key is a value that contains spaces 
}

Features unique to Ion:

{
  symbol: 'a symbol',     // symbols are interned Unicode strings
  "A null integer": null.int,
  annotated: age::35,     // the symbol "age" is attached to the value "35" as an annotation
  lists : 'hw grades'::[80, 85, 90], // any symbol can be used as an annotation 
  many_annot: I::have::many::annotations::true, // annotations are not nested, but rather, a list of annotations
  sexp: (this (is a [valid] "Ion") last::value + 42) // Ion S-expressions. 'this', 'is', 'a', 'valid', 'value', and '+' are symbols.
  _value: {{OiBTIKUgTyAASb8=}}, // blob value is represented as base64
  _value: {{"a b\0\xff"}}             // clob value is represented as an ASCII string with C-style escapes
  // ^ repeated names (keys) are allowed but generate a warning for undefined behavior 
}

Uses

Tooling and extensions

References

  1. ↑ "We are the Amazon Managed Blockchain and Amazon QLDB Teams – Ask the AWS Experts – November 29 @ 3PM PST / 6PM EST". 28 November 2018.
  2. ↑ "Announcing PartiQL: One query language for all your data". August 2019.