A Python implementation of Amazon Ion, a richly-typed, self-describing, hierarchical data serialization format. It offers interchangeable binary and text representations, with text being a superset of JSON. The library is currently at version 0.13.0 and is actively maintained with regular updates.
pip install amazon-ionVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use the `simpleion` module to serialize Python dictionaries into Ion text and binary formats, and deserialize them back. It also shows how to work with Ion-specific types like `IonPyTimestamp`.
Migrate code to Python 3. (Python 3.8+ is officially supported for current versions).
Ensure your environment uses Python 3.8 or newer.
Always test against your target `amazon-ion` version if using `simpleEnum`. It is present in 0.11.1 and later.
Ensure `cmake` is installed in your build environment to guarantee the C extension is utilized for optimal performance. You can check `ion.__IS_C_EXTENSION_SUPPORTED` to verify.
For streams with multiple top-level Ion values, use `ion.loads(ion_data, single_value=False)`.
Deconstruct the `datetime.datetime` object into its individual components when initializing `IonPyTimestamp`. For example: `dt = datetime(2023, 10, 27, 10, 30, 0); timestamp_py = IonPyTimestamp(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.microsecond, dt.tzinfo)`.
When converting a `datetime.datetime` object to `IonPyTimestamp`, you must pass its components individually. For example: `dt = datetime(2023, 10, 27, 10, 30, 0)`; then `timestamp_py = IonPyTimestamp(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.microsecond, dt.tzinfo)`.
Install the package using pip: 'pip install amazon.ion'.
Use the correct import statement: 'from amazon.ion import simpleion'.
Use the 'loads' function instead: 'from amazon.ion import simpleion; data = simpleion.loads(ion_string)'.
Ensure the Ion data is correctly formatted and 'loads' returns a valid object: 'data = simpleion.loads(ion_string); if data is not None: value = data['key']'.
Verify the Ion data string for correctness and ensure it adheres to the Ion format specifications.