I'm trying to get a JSON object like:
{
"username": "clelio",
"name": "Clelio de Paula",
}
and transform it in:
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 to use the simplejson and one method called jsonToClass():
>>> import simplejson as json
>>> u1 = User()
>>> u1.jsonToClass(face)
>>> u1.save()
This doesn't work. What is the easiest method to do what I want?