我想将json请求反序列化为类序列化程序,但无法获得正确的包装类。
这是我使用的json:
{
"NewData":
{
"UserID":"12345",
"CommunicationId":"11111",
"SessionId":"22222",
"StartTime":"2013-08-12",
"EndTime":"2013-08-13",
}
}
类序列化器应该是什么样的?
我有以下类,但我需要一个包装类。
class CommSerializer(serializers.Serializer):
'''Serializer for Comm documents
'''
UserID = serializers.IntegerField()
CommunicationId = serializers.IntegerField()
SessionId = serializers.IntegerField()
StartTime = serializers.CharField()
EndTime = serializers.CharField()
def restore_object(self, attrs, instance=None):
"""Create or update a new Comm (dict) instance.
"""
return dict(attrs)
谢谢,