Salesforce Apex Jsonを作成方法

MyObject obj = new MyObject();
obj.item1 = ‘aaa’;
obj.item2 = ‘bbb’;

MyObject obj1 = new MyObject();
obj1.item1 = ‘aaa’;

List<MyObject> objlist = new List<MyObject>();
objlist.add(obj);
objlist.add(obj1);

String jsonStr = JSON.serializePretty(objlist);

nullの項目をJsonから除外したい場合、
String jsonStr = JSON.serializePretty(objlist,true);

https://developer.salesforce.com/docs/atlas.ja-jp.apexcode.meta/apexcode/apex_class_System_Json.htm