You need to sign in to do that
Don't have an account?

JSON Parser not finding data...
I have a class that does a callout to which returns JSON like this:
and my code to parse is:
{ "personMatchResponse": { "inputParameters": { "parameter": { "name": "outputFieldOptions", "value": "jobFunction,managementLevel" } }, "matchResults": { "personMatchResults": { "personMatchResult": { "matchPersonInput": { "uniqueInputId": "Zoom-1" }, "personMatches": { "personMatch": { "firstName": "First", "lastName": "Last", "phone": "number", "currentEmployment": { "jobTitle": "Title", "jobFunction": "Function", "managementLevel": "C-Level", "company": { "companyId": 002400, } }, "industry": ["Software Development & Design", "Software", "Engineering Software"] } } } } } } }
and my code to parse is:
//Parse JSON JSONParser parser = JSON.createParser(res.getbody()); System.JSONToken token; string text; parser.nextToken(); // parser.nextToken(); // parser.nextToken(); // parser.nextToken(); // while((token = parser.nextToken()) != null) { // Parse the object if ((token = parser.getCurrentToken()) != JSONToken.END_OBJECT) { text = parser.getText(); if (token == JSONToken.FIELD_Name && text == 'personId' ) { token=parser.nextToken(); thisLead.Zoom_Info_ID__c = parser.getText(); thisLead.zisf__zoom_id__c = parser.getText(); } else if (token == JSONToken.FIELD_Name && text == 'companyId') { token=parser.nextToken(); thisLead.Zoom_Info_Company_ID__c = parser.getText(); } else if (token == JSONToken.FIELD_Name && text == 'phone') { token=parser.nextToken(); thisLead.Zoom_Info_Direct_Line__c = parser.getText(); } else if (token == JSONToken.FIELD_Name && text == 'jobTitle') { token=parser.nextToken(); thisLead.title = parser.getText(); } } // advance to next object //token = parser.nextToken(); if (token == JSONToken.END_ARRAY) { // we reached end of array break; } }
It was working fine before I added something to the request that caused the "inputParameters": { section to be returned. Is there a way to make it skip that section and just go the match results?
Help is greatly appreciated!
1) https://www.adminbooster.com/tool/json2apex
Your Apex class should be like that NOTE:- minar change i did in your JSOn
"industry": [{"Name":"Software Development & Design"} ,{"Name":"Software"}]
Thanks Amit,
But I am still a bit confused how to use the above class to parse the JSON, can you provide a bit more detail? It would be greatly appreciated!
but am unsure how to pull data from that