Starting from:

$29.99

DSCI551 Lab 4-DynamoDB Solution


2.  Export the item you created in task 1 as a JSON file, say books.json. Write a Python program convert.py that takes books.json and converts into a new JSON file with all data type fields removed (e.g., ‘S’, ‘N’, ‘SS’, ‘NS’, ‘L’, ‘M’) and corresponding values properly converted to values of right data types. For example,
{'author': {'S': 'bill clinton'}, 'year': {'N': '2010'}, 'keywords': {'SS': ['biography', 'history']}, 'prices': {'L': [{'N': '25.2'}, {'N': '30'}, {'S': 'unknown'}]}, 'ratings': {'M': {'amazon': {'N': '5'}, 'b&n': {'N': '4.5'}}}, 'title': {'S': 'my life'}}
=>
{'author': 'bill clinton', 'year': 2010, 'keywords': ['biography', 'history'], 'prices': [25.2, 30, 'unknown'], 'ratings': {'amazon': 5, 'b&n': 4.5}, 'title': 'my life'}
Execution format: python3 convert.py <input.json> <output.json>
where input.json is the json file you exported from DynamoDB, e.g., books.json, and output.json stores the converted JSON data.
Submission: submit the following files (do not put them in a zip file).
1. input.json (The exported JSON file of the table you created for Q1)
2. convert.py
3. output.json (The converted JSON file)
Notes:
● You can use the Python json library.
● You can assume that the attributes in the table only have the following data types:
string, number, list, stringSet, numberSet, and map.
● You can assume that the values in a list and the values of the keys in a map are either string or number.

More products