I have just pushed an update to the sObject serialization project up to GitHub.  This update is a class to serialize/deserialize sObjects into JSON.  This removes the dependance on the native string.valueOf() method that the earlier serializer was dependent on and also means that the objects are converted to a standard format rather than a proprietary one.

I followed the specification for the JSON format as specified on the JSON.org website.  The biggest issue I had was around accessing fields from the object that hadn’t been selected in the SOQL.  I couldn’t find a way to test to see if the field was available which has unfortunately led me to have to use exception handling to control the situation.  I’m not keen on using the try/catch construct to control program flow but I can’t see another way around this it at the moment so have reluctantly left the swallowing catch in the code.

The serializer implements the same serializer interface as the StringSerializer does which means if you want to change serialization methods you can simply swap the StringSerializer out for the JSONSerializer and everything should continue to work as before.

With the introduction of the REST API from Salesforce this class is fairly redundant from an integration stand point.  However for passing sObjects to @future methods this still has legs; hence the update.

As ever this is up on GutHub as Open Source and as such is there for everyone to use, steal or enhance so feel free to dig into it and make use of it.