DynamoDB Json
DynamoDB json util to load and dump strings of Dynamodb json format to python object and vise-versa
Install
just use pip:
pip install dynamodb-json
Use
The dynamodb-json util works the same as json loads and dumps functions:
import time
import uuid
from datetime import datetime
from decimal import Decimal
from dynamodb_json import json_util as json
json_ = {"MyString": "a",
"num": 4,
"MyBool": False,
"my_dict": {"my_date": datetime.utcnow()},
"MyNone": None,
"MyZero": 0,
"myDecimal": Decimal("19.2"),
"myLong": long(1938475658493),
"MyNestedDict": {
"my_other_nested": {
"name": "John",
"surname": "Lennon",
"MyOtherNone": None,
"floaty": float(29.4),
"myList": [1, 3, 4, 5, 6, "This Is Sparta!"],
"mySet": {1, 3, 4, 5, 6},
"myUUID": uuid.uuid4(),
"time": time.time()
}
}
}
dynamodb_json = json.dumps(json_)
json.loads(dynamodb_json)