You can construct JSON content, element by element, using the standard JSON encoding. To do so, use the methods in the JSONGenerator class.
This example generates a JSON string in pretty print format by using the methods of the JSONGenerator class. The example first adds a number field and a string field, and then adds a field to contain an object field of a list of integers, which gets deserialized properly. Next, it adds the A object into the Object A field, which also gets deserialized.
Contains methods used to serialize objects into JSON content using the standard JSON encoding.
The System.JSONGenerator class is provided to enable the generation of standard JSON-encoded content and gives you more control on the structure of the JSON output.
The following are methods for JSONGenerator. All are instance methods.
“Explore – Techila Global Services, A Salesforce development company”