• Claudio Chiaro 12
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
When serializing Apex objects, JSON.serialize() still includes null class variables even though the documentation seems to claim this was fixed back in Apex version 28. (I've tested with versions up to the current version -- 36)

Example Apex class:
public with sharing class xtmp_TestJSON {
    public String SomeText;
    public String SomeOtherText;
}
and test JSON.serialize() using:
xtmp_TestJSON req = new xtmp_TestJSON();
req.SomeText = 'Hi';

System.debug('====> data: ' + JSON.serialize(req));
Output is:
====> data: {"SomeText":"Hi","SomeOtherText":null}

Any suggestions on how to "fix" this?

Thanks,

-L