API Changes
- This release adds a DOM-style API for easily working with Ion values in memory.
- Read Ion values from a stream using:
let ionValue = ion.load(dataSource);
- Ion values extend native JS types, so they are often interchangeable for the corresponding JS type.
let person = ion.load('{name: "Michelle", age: 46}'); console.log("Hello, " + person.name);
- Ion values implement the strongly-typed
dom.Value
interface, making them straightforward to work with in TypeScript.let name: string = ion.load('{name: "Michelle", age: 46}').get('name').stringValue();
- Convert an existing JS value to an Ion value using:
let ionValue = ion.dom.Value.from(jsValue);
- Write Ion values to an existing Ion
Writer
using:ionValue.writeTo(writer);
- Write Ion values to a
Uint8Array
orstring
using:let ionBytes = ion.dumpBinary(ionValue); let ionText = ion.dumpText(ionValue); let neatlySpacedIonText = ion.dumpPrettyText(ionValue);
- Down-convert Ion to a JSON string using:
let jsonText = JSON.stringify(ionValue);
- The DOM API leverages JS runtime features introduced in ES6, which is supported in all current versions of NodeJS (v10+) and all modern browsers. It is not supported in older runtimes.
- Read Ion values from a stream using:
IonWriter#writeValues(reader: Reader)
will now work when theReader
andWriter
are positioned at depths greater than zero.- Calling
stepOut()
when theReader
is at the top level will nowthrow
. - Downconversions from
JSBI
toNumber
now gracefully lose precision rather than clamping values to the safely representableNumber
range. Reader.value()
is deprecated in favor of more strongly typed variants (stringValue()
,decimalValue()
, etc)jsbi
is now a peer dependency; in addition to depending onion-js
, consumers are now required to declare a dependency on this package.
Bug Fixes
- #165: When reading Unicode escape sequences, the parser would sometimes treat code points as character codes.
- #478: Text symbol ID
$0
should have thrown when encountered inReader.annotations()
but didn't. - #513: Text symbol IDs (e.g.
$3
) would be read literally ($3
) rather than resolved ($ion_symbol_table
). - #514: In some circumstances,
Reader
state was not correctly reset after skipping values. - #515:
\r\n
escape sequence handling now adheres to the spec.
Work for this release was tracked in Milestone 4. The complete list of commits included in v4.0.0
can be found here.