Salesforce Developer Tutorial: How to use Wrapper Classes in Apex to Simplify your Integrations

preview_player
Показать описание
In this episode we go over how to use wrapper classes to simplify your REST integrations when you receive JSON responses. Instead of manually parsing everything, you can use wrappers to simply your life a TON! Hopefully this helps speed up the dev time on your next integration a bunch.

GitHub Repo:

Follow all of our social media here:

Salesforce development books I recommend:

Good Non-SF Specific Development Books:

-------------------------------------------------------------------------------------------------------------------------

Table of Contents:

0:00 - Intro
0:20 - Go vote on next weeks video topic!
0:55 - Why are wrapper classes so important?
2:32 - Reddit JSON Example
4:30 - The importance of using Postman
6:32 - Using the JSON2Apex Heroku App
7:58 - Trimming the wrapper class to only reference what you need
18:10 - Making the class visible to Lightning Components
19:26 - Building the integration with Reddit
43:09 - Outro

DISCLAIMER: The views and ideas expressed on this YouTube channel and blog are based on past development experiences and may not always work for your particular scenarios. The advice in these videos may also become outdated as technology advances. They should be used as examples for educational purposes only. Using any shown solutions in your own org is not advisable since they are example scenarios.

#salesforce #salesforcedeveloper #salesforceadmin
Рекомендации по теме
Комментарии
Автор

really good information, i learned this doing my official first integration some days ago, so i can tell this is really helpful.

ignaciomartin
Автор

Great video! Well organized and informative! You have a talent for teaching.

danieljeffrey
Автор

Nice work, Matt. This is a great explanation of wrapper class use and an introduction to json2apex.

slackularo
Автор

Perfect video again! I will have to watch the others too! Thanks!!

jean-francoiscarrier
Автор

Good information, Matt! Much appreciated.

paxhaven
Автор

Yes, I agree with Daniel Jeffrey, you have a talent for teaching. THANK YOU!! & don't change! In past life, I was an OO ABAP developer (yes it is object-oriented..yeah..i know). You are the equivalent of Thomas Jung @SAP! I hope SF scoops you up, if they haven't already!

kimberlyholland
Автор

Nice Class. Makes me feel a little less timid about approaching the integrations via Apex vs middleware

GreeveCapricous
Автор

Thanks Matt for this informative Tutorial. I would like to know if you have made any videos for inbound integrations into salesforce? Thank you.

ManiMahal-pnip
Автор

Nice video! Thanks for posting it!

@36:30 you said string parsing is enormous overhead.

What if I just use String fieldValue = '"fieldName":"', '', ' ); to get a single field??

Asssume I just need few fields from the JSON response, that would be a lot faster than using wrapper class and deserializing JSON, wouldn't it?

PuerinTheHunter
Автор

My json2apex output file looks different with the JSONParser method included in all methods, and each value includes the {get;set;}, some values include _Z, like "public Integer limit_Z {get;set;} // in json: limit" . This makes sense for my use case as I have system values in the json payload and would need a way to parse through this using JSONParser method. I'm wondering how do I initiate this JSONParser method when generating my wrapper class @CodingWithTheForce? Or if you were to include this in your example above how would you initiate that. I've included a sample of the wrapper class. Thanks very much, your videos have been super useful to develop my understanding of rest integration.

public class JSON2Apex {
public class Data {
public String client_ref {get;set;}
public Integer limit_Z {get;set;} // in json: limit

public Data(JSONParser parser) {
while (parser.nextToken() != System.JSONToken.END_OBJECT) {
if (parser.getCurrentToken() == System.JSONToken.FIELD_NAME) {
text = parser.getText();
(parser.nextToken() != System.JSONToken.VALUE_NULL) {
(text == 'client_ref') {
= parser.getText();
else if (text == 'limit') {
= parser.getIntegerValue();
else {
'Data consuming unrecognized property: '+text);



}
}
}
}

MrBenjo
Автор

How to parse html with img from json you have and insert into salesforce object??? Could you please suggest.

TK-vtep
Автор

could you possibly do a video explaining these wrapper classes in more detail? I'm having trouble figuring out how to access data that's nested in the wrapper class. it's silly but I'm practicing callouts by making a salesforce pokedex and getting the info from callouts to the pokeapi. I was able to get all the names of the pokemon by using this video. but when I go to the pokemon's individual page there are nested json objects and arrays.

I think it would be really helpful if you did a couple of different callouts with nested and varied data. I'm fairly new to apex. parsing json is so much easier in javascript and python, lol.

walkswithcedarandmaddy
Автор

Hello could you please do few more sessions on same wrapper class integration topic which is also known as Data transfer object it would be very much helpful.

mailme
Автор

3:30 point of this vdo
4:30 postman or use han
6:55 json etto apex class Han direct

shaswat
Автор

Hi, could you please make a detailed video on Test Class on every aspect??

pavandkbose
Автор

You should have picked a more difficult JSON data.

romanregmi