I want to convert Amazon Ion file from S3 bucket to JSON format.
I am trying following code
import json
import boto3
s3 = boto3.resource('s3')
bucket = s3.Bucket('some/path/')
ion_body = bucket.Object('xxxxxxxxxxxxxx.ion').get()['Body'].read().decode("utf-8")
json.loads(ion_body)
But I am getting following JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 3 (char 2)
error. Because in Ion file keys are declared without quotes.
Amazon Ion document says we can down convert Ion to Json. But I didn't get any way. Please help me. Thanks!
The Ion Cookbook has an example for this (reference)
In addition to amazon.ion, you'll also need to install jsonconversion.
For your case, you'd do: