I am trying to get a JSON object, for example:
{ "username": "clelio", "name": "Clelio de Paula", }
and convert it to:
class User(models.Model): name = models.CharField(max_length=30) username = models.CharField(max_length=20) def jsonToClass(s): aux = json.dumps(s, self) self.name = aux['name'] self.id = aux['id']
So I tried using simplejson and one method called jsonToClass() :
>>> import simplejson as json >>> u1 = User() >>> u1.jsonToClass(face) >>> u1.save()
This does not work. What is the easiest way to do what I want?
json python object django
cleliodpaula
source share