I have been using JSON.Serialize method extensively in one of customer’s project. Today salesforce has started rolling out Spring ’13 release on sandboxes. My customer’s sandbox( cs11) is not listed on https://trust.salesforce.com/trust/maintenance/ but still Spring ’13 is available in this sandbox.
I have noticed a change that if I serialize a sObject, Json Serializer doesn’t return fields with null value in json. Before Spring ’13 release it was working fine.
If this was a needed change to reduce size of serialized json, Salesforce should have made this version specific change or a overloaded method to keep backward compatibility. It has broken 30%-40% of my code that I will need to rewrite.
Salesforce please undo this change.
The Apex development team changed the behavior of the JSON serialization in response to several customer issues.
As you are aware, we will typically version changes to the system behavior where possible, in order to protect backward compatibility. There are situations in which we do not version behavior, however. We made an assumption that JSON parsers would not have an issue not receiving null values, since the information received is not relevant. It’s like the junk mail you reflexively throw out when sifting through your mail.
As per your post, it’s clear that some parsing strategies depend on null values being included in the JSON output. We apologize that our assumption was incorrect, and that your integration and others were unable to operate with the new version.
We have undone the change for the Spring ’13 release. To support the original customer cases that prompted these changes, we will version in the originally intended fix in the Summer release.
Product Manager, Apex Code