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
Reshmi SmijuReshmi Smiju 

Trailhead Module : Describe JSON2Apex

Hi,

This is regarding to one of the module in Trailhead : Apex REST Callout. In this, author is menioning about the JASON2Apex. I  didnt understand to how to use that. Pls help me on this. Thanks in Advance.

Regards
Reshmi
Best Answer chosen by Reshmi Smiju
Amit Chaudhary 8Amit Chaudhary 8
Please check below link. In that you can convert your JSON into apex class
http://json2apexengine.somee.com/

For example if you have below json and you want a wrapper class for same
JSON
{"animals": ["pesky porcupine", "hungry hippo", "squeaky squirrel"]}
APEX
public class JsonParser{
		public list<String> animals{get;set;}
}
User-added image

 

All Answers

Amit Chaudhary 8Amit Chaudhary 8
Please check below link. In that you can convert your JSON into apex class
http://json2apexengine.somee.com/

For example if you have below json and you want a wrapper class for same
JSON
{"animals": ["pesky porcupine", "hungry hippo", "squeaky squirrel"]}
APEX
public class JsonParser{
		public list<String> animals{get;set;}
}
User-added image

 
This was selected as the best answer
Daniel BallingerDaniel Ballinger
With the Trailhead Apex Integration Services - Apex REST Callouts (https://developer.salesforce.com/trailhead/apex_integration_services/apex_integration_rest_callouts) the reference would have been to the https://json2apex.herokuapp.com/ service. This is the version created by Superfell and Metadata, both Salesforce employees at the time it was made. The source is also available on Github (https://github.com/superfell/json2apex).

I only mention this as it is the version they use, rather than a version provided by a third party.