In this page, we tried to give a comparative study of Ion w.r.t. JSON. If you don’t have prior knowledge of JSON and/or you want to directly jump-in to Ion specs, refer to Ion specification at git-hub.
Ion has two formats.
- The text format (just like JSON). This is good for human readability and sending data to client applications that are only JSON aware.
- The binary format (this option doesn’t exist in JSON). The strength of binary format is leveraged when we store/process large amounts of data. Binary format is far most efficient than text format. This really matters to organizations that spend several hundreds of millions of dollars a year on the hardware serving web applications/cloud storage/cloud computing.
- number (no precision, nothing)
- true (primitive)
- false (primitive)
- null (primitive)
Ion only types
- string – Unicode text literals (eg. “Hello World!”)
- struct – Unordered collections of tagged values (same as object in JSON)
- list – Ordered collections of values (same as array in JSON)
- null – A generic null value
- bool – Boolean values (eg. true, false, null.bool)
- int – Signed integers of arbitrary size (eg., 0, -23, 0xBAD, 0b1001). An underscore is allowed to separate digits for the sake of human readability.
- float – Binary-encoded floating point numbers (IEEE 64-bit). (eg. 1.3e0, 0xFF)
- decimal – Decimal-encoded real numbers of arbitrary precision (eg. 23., 2.3d1, 0.23d2 (all are equivalent decimal notations))
- timestamp – Date/time/timezone moments of arbitrary precision (eg. 2016-01-01T00:00-00:00, 2016T, 2016-01-01T00:00-00:00+03:00 // this is with local offset)
- symbol – identifiers (eg. ‘student name’, studentName, student_name) If symbol has no spaces, single quotes are not required.
- blob – Binary data of user-defined encoding
- clob – Text data of user-defined encoding
- sexp – Ordered collections of values with application-defined semantics
JSON doesn’t support custom types but in Ion you can define your custom-types defined through annotations. Which means that Ion is extensible indefinitely and thus called more expressive or richly typed representation.