function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Anton | De OndernemerAnton | De Ondernemer 

JSON not suppressing null values

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_System_Json.htm

according to the above link, since the summer '16 release it should be possible to suppress null values:
serialize(objectToSerialize, suppressApexObjectNulls)
 
String customJSONBody = JSON.serialize(myObject, true);

If I do the following code and debug the string, it still shows the null values.
Is it bugged? anybody knows a workaround?
Charisse de BelenCharisse de Belen
Hi Anton,

Try checking if your object class is using the current API version. 
Anton | De OndernemerAnton | De Ondernemer
Version 39.0, so should be good.
Anton | De OndernemerAnton | De Ondernemer
Never mind, it works somehow when I changed other fields. I honestly don't know what went wrong.
Charisse de BelenCharisse de Belen
Hmm, that's interesting. I'm glad you got it working, though. If you ever figure out what the problem was, please feel free to update this question and mark your answer as the Best Answer in case the info can help other people. Thanks!