Jump to content

Ion (serialization format)

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by KolbertBot (talk | contribs) at 16:51, 15 December 2017 (Bot: HTTP→HTTPS (v478)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Ion
Filename extension
.ion
Internet media typeapplication/ion
Developed byAmazon
Type of formatData interchange
Websiteamznlabs.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

  • null: An empty value
  • bool: Boolean values
  • string: Unicode text literals
  • list: Ordered heterogeneous collection of Ion values
  • struct: Unordered collection of key/value pairs

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

  • int: Signed integers of arbitrary size
  • float: 64-bit IEEE binary-encoded floating point numbers
  • decimal: Decimal-encoded real numbers of arbitrary precision

Ion adds these types:

  • timestamp: Date/time/timezone moments of arbitrary precision
  • symbol: Unicode symbolic atoms (aka identifiers)
  • blob: Binary data of user-defined encoding
  • clob: Text data of user-defined encoding
  • sexp: 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., null.int, null.struct).

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).

Examples

Sample document

{
  "key": "value",
  "A float value": -31415e-4,
  "An int value": null.int
}