pyion2json

raw JSON →
0.0.2 verified Fri May 01 auth: no python maintenance

Convert Amazon Ion documents to JSON. Version 0.0.2 is the latest, released March 2020. Low activity, likely stable but not actively maintained.

pip install pyion2json
error ModuleNotFoundError: No module named 'amazon'
cause The dependency amazon.ion is not installed.
fix
pip install amazon.ion
error AttributeError: module 'pyion2json' has no attribute 'ion_to_json'
cause Incorrect import or old version installed.
fix
Use: from pyion2json import ion_to_json
gotcha The library uses amazon.ion internally; if you have a different Ion parser installed, conflicts may occur.
fix Ensure amazon.ion is the version compatible with this library.
gotcha ion_cursor_to_json expects an IonCursor object, not a raw iterable. Passing a list of Ion values will fail.
fix Create an IonCursor from your iterable using amazon.ion's cursor API.

Loads an Ion value and converts to JSON string.

from pyion2json import ion_to_json
import amazon.ion.simpleion as ion

ion_data = b'{name: "Alice", age: 30}'
ion_val = ion.loads(ion_data)
json_str = ion_to_json(ion_val)
print(json_str)