Before I go re-invent the wheel is there a framework or module for de-
serialization JSON back into python objects?

I've been doing something like this and a played around with setattr()


    def decode_from_dict(self, cls, vals):
        #obj = cls()
        obj = cls
        for key, val in vals.items():
            print obj, key, val
            setattr(obj, key, val)
        return obj

    def decode_object(self,d):
        blah = CurriculumOrderItemModel()
        return self.decode_from_dict(blah, d)

    @expose()
    def order_up(self):
        order = '[{"orderID": 123334456, "moduleTitle": "Public/
Financial D&O Liability Insurance"}]'
        result = json.loads(order, object_hook=self.decode_object)

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en.

Reply via email to