Ion (serialization format)
{{other uses|Ion (disambiguation)}}
{{multiple issues|
{{notability|date=July 2017}}
{{external links|date=August 2024}}
}}
{{Infobox file format
|name = Ion
|icon =
|extension = .ion
|mime =
|developer = Amazon
|type = Data interchange
|url = {{URL|https://amzn.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
- {{code|null}}: An empty value
- {{code|bool}}: Boolean values
- {{code|string}}: Unicode text literals
- {{code|list}}: Ordered heterogeneous collection of Ion values
- {{code|struct}}: Unordered collection of key/value pairs
The nebulous JSON 'number' type is strictly defined in Ion to be one of
- {{code|int}}: Signed integers of arbitrary size
- {{code|float}}: 64-bit IEEE binary-encoded floating point numbers
- {{code|decimal}}: Decimal-encoded real numbers of arbitrary precision
Ion adds these types:
- {{code|timestamp}}: Date/time/time zone moments of arbitrary precision
- {{code|symbol}}: Unicode symbolic atoms (aka identifiers)
- {{code|blob}}: Binary data of user-defined encoding
- {{code|clob}}: Text data of user-defined encoding
- {{code|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., {{code|null.int}}, {{code|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).
Implementations
- [http://amzn.github.io/ion-docs/libs.html Amazon supported library implementations]
- [https://github.com/dhhoang/IonDotnet C#]
- [https://github.com/amzn/ion-go Go Lang]
- [https://github.com/amzn/ion-python Python]
- [https://github.com/amzn/ion-js JS]
Examples
=Sample document=
// 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: {{OiBTIKUgTyAASb8=}},
_value: {{"a b"}}
}
=Uses=
- Amazon's Quantum Ledger Database (QLDB) stores data in Ion documents.{{Cite web|url=https://www.reddit.com/r/aws/comments/a18awq/we_are_the_amazon_managed_blockchain_and_amazon/|title=We are the Amazon Managed Blockchain and Amazon QLDB Teams – Ask the AWS Experts – November 29 @ 3PM PST / 6PM EST|date=28 November 2018}}
- [https://partiql.org/ PartiQL], an open source SQL-based query language also by Amazon, is built upon Ion. PartiQL supported queries are used by QLDB, S3Select.{{Cite web|url=https://aws.amazon.com/blogs/opensource/announcing-partiql-one-query-language-for-all-your-data/|title=Announcing PartiQL: One query language for all your data|date=August 2019}}
Tooling and extensions
- [https://github.com/amzn/ion-java-path-extraction Ion Path Extractor API] aims to combine the convenience of a DOM API with the speed of a streaming API.
- IDE support
- [https://github.com/amzn/ion-eclipse-plugin Eclipse]
- [https://github.com/amzn/ion-intellij-plugin IntelliJ]
- [https://github.com/FasterXML/jackson-dataformats-binary/tree/master/ion Jackson data format module for Ion]
- [https://github.com/amzn/ion-hive-serde Apache Hive SerDe] for Ion
- [https://amzn.github.io/ion-schema/ Ion Schema]
- [https://amzn.github.io/ion-schema/docs/spec.html Specification]
- [https://github.com/amzn/ion-schema-kotlin Implementations]
- [https://amzn.github.io/ion-hash/ Ion Hash] defines an algorithm for constructing a hash for any Ion value.
- [https://amzn.github.io/ion-hash/docs/spec.html Specification]
- [https://amzn.github.io/ion-hash/libs.html Implementations]
References
{{Reflist}}
External links
- [https://amznlabs.github.io/ion-docs/spec.html Ion specification]
- [http://amzn.github.io/ion-docs/libs.html Amazon supported language implementations]
- [http://www.javadoc.io/doc/software.amazon.ion/ion-java/1.0.0 Java API documentation]
- [https://dev.to/goaty92/p1-writing-a-serialization-library-in-c-the-case-for-ion--24p0 C# implementation]
{{Data Exchange}}