[Python-ideas] Json object-level serializer (original) (raw)
Tarek Ziadé ziade.tarek at gmail.com
Thu Jul 29 13:35:41 CEST 2010
- Previous message: [Python-ideas] str.split with empty separator
- Next message: [Python-ideas] Json object-level serializer
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello,
What about adding in the json package the ability for an object to provide a different object to serialize ? This would be useful to translate a class into a structure that can be passed to json.dumps
So, it json is provided, its used for serialization instead of the object itself:
import json class MyComplexClass(object): ... def json(self): ... return 'json' ... o = MyComplexClass() json.dumps(o) '"json"'
Cheers Tarek
-- Tarek Ziadé | http://ziade.org
- Previous message: [Python-ideas] str.split with empty separator
- Next message: [Python-ideas] Json object-level serializer
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]