[Baypiggies] newbie question - json as pickler

K. Richard Pixley rich at noir.com
Mon Feb 22 09:08:37 CET 2010


I was hoping to use json as a direct pickle replacement for some log 
files, wire transfers, and state dump/restores, at least for debugging, 
because it's essentially human readable.  But I've run into two problems.

Problem #1: most json encoders, (including the standard library json 
module), don't encode/decode arbitrary objects.  They seem to be aiming 
for cross language exchange rather than persistence or serialization of 
python-to-python transfers.  I have found a couple on the cheese shop 
that do use a standard encoding, so this isn't necessarily a blocker.

Problem #2: the object encoding serializers that I've found are strictly 
string->object and object->string.  This would seem to make a number of 
things awkward.  Spitting out a sequence of objects as a sequence of 
strings is easy.  However, it's looking to me as though reading that 
sequence of strings will require parsing the incoming stream in order to 
divide them up into chunks suitable for handing off to the 
deserializer.  This seems like it makes the serializers essentially useless.

I feel like I must be missing something here.  Does anyone else see it?  
Is there an obvious way to break up the byte stream?  Is there an easy 
way to tease the standard library coder into coding arbitrary objects?

--rich




More information about the Baypiggies mailing list