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

help with mapping JSON2Apex Class to Salesforce Object Fields

Hello, I'm a complete newbie to API integration - I have REST web service exposed to consume third party data which is to  update records in Salesforce. I've got the JSON2Apex Class as the JSON is nested but unsure how to use this to map JSON fields/objects to Salesforce field names. I'm struggling to find any guidance online, please could someone point me in the right direction?
VinayVinay (Salesforce Developers) 

Hope below links gives you more information on JSON deserialization.

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Vinay Kumar
Thanks Vinay, I think thats helped me to get a little further but i'm stuck withhow to refer to nested json. 

Can anyone please help me fix the below code?

exmaple JSON:
	"resourceType": "Human",
	"id": "1234567890",
	"text": {
"status": "generated",},
			"use": "usual",
			"value": "1234567890"
	"active": true,
	"name": {
		"use": "usual",
		"family": "Smith",
	"mobile": {
		"system": "phone",
		"value": "077123456",
		"use": "mobile"

Wrapper Class:
global with sharing class HumanDeserialize {    
    global List<Humans> lstHumanRecords;
    global HumanDeserialize(){lstHumanRecords = new List<Humans>();}
    global class Humans{
        global String resourceType;
        global String id;
        global List <text> text;  
          global class text{
            global List <identifier> identifier;
       global class identifier{
        	global String use;
        	global String value;

Rest upsert class:
global with sharing class HumanUpdateManager {
    global static HumanDeserialize doPutHuman(HumanDeserialize requestHumanDeserialize){
        HumanDeserialize responseHumanDeserialize = new HumanDeserialize();
        List<HumanDeserialize.Humans> lsHumanDeserializes = new List<HumanDeserialize.Humans>();
        List<Human__c> lstHumanRecords = new List<Human__c>();
        for(HumanDeserialize.Humans Humandeserialize : requestHumanDeserialize.lstHumanRecords){
    		Human__c HumanRecord = new Human__c();
        	HumanRecord.ExtID__c = requestHumanDeserialize.identifier;
        upsert lstHumanRecords;
             	responseHumanDeserialize = requestHumanDeserialize;
        responseHumanDeserialize.identifier = HumanRecord.ExtID__c;
        return  responseHumanDeserialize;