You need to sign in to do that
Don't have an account?
David Lee 8
JSONGenerator and JSONParser do not work
I am trying to generate and parse JSON, but JSONGenerator and JSONParser do not seem to work. Execution stops without any errors.
for example, run the following code in the console:
for example, run the following code in the console:
List<Contact> contacts = [SELECT Id, Name FROM Contact LIMIT 10]; System.debug(1); JSONGenerator generator = JSON.createGenerator(true); System.debug(2); generator.writeStartObject(); generator.writeNumberField('count', contacts.size()) generator.writeEndObject(); String jsonString = generator.getAsString(); System.debug(jsonString);All I get is USER_DEBUG [14]|DEBUG|1. There are no errors in the output. Same happens when I try to use JSONParser.
Try this. Should work
Did you really try the code which I shared because in your code you were missing some syntax.
http://salesforcecodes.com/related-contacts-display-for-account-using-jsongenerator/