This article has multiple issues. Please help improve it or discuss these issues on the talk page . (Learn how and when to remove these messages)
|
| Ion | |
|---|---|
| Filename extension | .ion |
| Internet media type | application/ion |
| Developed by | Amazon |
| Type of format | Data interchange |
| Website | amzn |
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.
As a superset of JSON, Ion includes the following data types
null: An empty value (for JSON compatibility)bool: Boolean valuesstring: Unicode text literalslist: Ordered heterogeneous collection of Ion values (extension of JSON array)struct: Unordered collection of key/value pairs (extension of JSON object)The nebulous JSON 'number' type is strictly defined in Ion to be one of
int: Signed integers of arbitrary sizefloat: 64-bit IEEE binary-encoded floating point numbersdecimal: Decimal-encoded real numbers of arbitrary precisionIon adds these types:
timestamp: Date/time/time zone moments of arbitrary precisionsymbol: Unicode symbolic atoms (aka identifiers), stored as interned strings in binary formatblob: Binary data of user-defined encodingclob: Text data of user-defined encodingsexp: Nested list of values (equivalent to an S-expression) with application-defined semanticsEach 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).
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 JSONnums: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 annotationlists:'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 annotationssexp:(this(isa[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 }