I am getting some very odd behavior from the JSON serializer where if the Sobject was originally instantiated from a SOQL query it will exclude any fields that were not part of my query from the serialized JSON string even if I fill in those fields later in my code.
sample code:
Contact con = [select id, lastname, accountid from Contact limit 1];
con.firstname='foo';
string jsonstring = Json.serialize(con);
system.debug(jsonstring);
System.Assert(jsonstring.contains('foo') == false); //this should not be happening
Contact newcon = new Contact(id=con.ID,lastname=con.Lastname,accountid=con.AccountID);
newcon.firstname='foo';
jsonstring = Json.serialize(newcon);
system.debug(jsonstring);
System.Assert(jsonstring.contains('foo'));
UPDATE: This was fixed in Spring '13!
Contact con = [select id, lastname, accountid from Contact limit 1]; con.firstname='foo'; System.debug('firstName=' + con.firstName);; however take out thecon.firstname='foo';and there will be an error. – Peter Knolle Oct 20 '12 at 14:21