Ion (serialization format)

From English Wikipedia @ Freddythechick
Ion
Filename extension
.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

  • <syntaxhighlight lang="text" class="" style="" inline="1">null</syntaxhighlight>: An empty value
  • <syntaxhighlight lang="text" class="" style="" inline="1">bool</syntaxhighlight>: Boolean values
  • <syntaxhighlight lang="text" class="" style="" inline="1">string</syntaxhighlight>: Unicode text literals
  • <syntaxhighlight lang="text" class="" style="" inline="1">list</syntaxhighlight>: Ordered heterogeneous collection of Ion values
  • <syntaxhighlight lang="text" class="" style="" inline="1">struct</syntaxhighlight>: Unordered collection of key/value pairs

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

  • <syntaxhighlight lang="text" class="" style="" inline="1">int</syntaxhighlight>: Signed integers of arbitrary size
  • <syntaxhighlight lang="text" class="" style="" inline="1">float</syntaxhighlight>: 64-bit IEEE binary-encoded floating point numbers
  • <syntaxhighlight lang="text" class="" style="" inline="1">decimal</syntaxhighlight>: Decimal-encoded real numbers of arbitrary precision

Ion adds these types:

  • <syntaxhighlight lang="text" class="" style="" inline="1">timestamp</syntaxhighlight>: Date/time/time zone moments of arbitrary precision
  • <syntaxhighlight lang="text" class="" style="" inline="1">symbol</syntaxhighlight>: Unicode symbolic atoms (aka identifiers)
  • <syntaxhighlight lang="text" class="" style="" inline="1">blob</syntaxhighlight>: Binary data of user-defined encoding
  • <syntaxhighlight lang="text" class="" style="" inline="1">clob</syntaxhighlight>: Text data of user-defined encoding
  • <syntaxhighlight lang="text" class="" style="" inline="1">sexp</syntaxhighlight>: Ordered collections of values with application-defined semantics

Each Ion type supports a null variant, indicating a lack of value while maintaining a strict type (e.g., <syntaxhighlight lang="text" class="" style="" inline="1">null.int</syntaxhighlight>, <syntaxhighlight lang="text" class="" style="" inline="1">null.struct</syntaxhighlight>).

The Ion format permits annotations to any value in the form of symbols. Such annotations may be used as metadata for otherwise opaque data (such as a blob).

Implementations

Examples

Sample document

<syntaxhighlight lang="js"> // comments are allowed in Ion files 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 value': 31415e-4,  // key is a value that contains spaces 
 "An int value": .int,
 annotated: age::35,     // age here is the annotation to number 35
 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, 
 _value: Template:OiBTIKUgTyAASb8=,
 _value: Template:"a b"

} </syntaxhighlight>

Uses

  • Amazon's Quantum Ledger Database (QLDB) stores data in Ion documents.[1]
  • PartiQL, an open source SQL-based query language also by Amazon, is built upon Ion. PartiQL supported queries are used by QLDB, S3Select.[2]

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.

External links