我无法从 PynamoDB 实例获取 JSON 表示。这是模型。
class MyTest(Model):
"""
Model class representing the Golden table attributes.
"""
class Meta:
table_name = "my-test"
# Query Fields
Id = UnicodeAttribute(hash_key=True)
SomeInfo = MapAttribute(default={})
SomeInfo1 = UnicodeAttribute(null=True)
my_test = MyTest(Id='123', SomeInfo={}, SomeInfo1='testing')
我需要的是 my_test 的 JSON 表示。
我尝试过的事情是。
my_test.to_dict() - 这给出了一个非属性错误
json.dumps(my_test.to_dict(), 缩进=2)
任何帮助,将不胜感激。