0

When individuals fill out a survey through an outside source, the JSON data gets stored in Salesforce as a Long Text Area in a custom Survey__c object (about 25,000 characters). There are hundreds of questions asked, and I would like to store only a few particular responses as a field on the Survey__c. For example, questions 322 and 340.

I need to create a utility that can be used in a trigger for future incoming Survey__c records, as well as used in a Batch so that we can update fields for existing Survey__c records.

I have no idea how to parse the data just to get the particular "Q322" and "Q340" values. I have been reading into how to parse JSON using Apex, and keep seeing information about creating maps of all the values - is this necessary if I only need a few out of the hundreds?

I have tried using things like JSON2Apex, but I don't think I understand enough about Apex to tell what it was really doing or how to take advantage of it.

I suppose I hardly know how to get started with this. Any help is appreciated.

Edit: I was encouraged to share the JSON:

{"result":{"responseId":"R_2q8m84s2YQvygki","values":{"startDate":"2022-10-06T22:17:38Z","endDate":"2022-10-06T22:21:21Z","status":0,"ipAddress":"71.105.116.210","progress":100,"duration":223,"finished":1,"recordedDate":"2022-10-06T22:21:22.323Z","locationLatitude":"40.5697","locationLongitude":"-74.1184","distributionChannel":"anonymous","userLanguage":"EN","QID141":1,"QID141_DO":["1","2"],"QID335_4":"Atest","QID335_22":"Mu1116","QID335_6":"atest+1116@abcd.com","QID335_DO":["4","22","5","6","7","23"],"QID340":2,"QID340_DO":["1","2","3","4","5","6","7","8","9","10"],"QID205":11,"QID205_DO":["1","4","5","6","7","8","9","10","11"],"QID206":7,"QID206_DO":["1","4","5","6","7","8","9","10","11"],"QID107":3,"QID107_DO":["1","2","3","4","5"],"QID105":["23"],"QID105_DO":["23","24","25","26","27","30","28"],"QID165":["3"],"QID165_DO":["1","2","3","4","5","6","7","8","9","10","11","12"],"QID100":4,"QID100_DO":["1","2","3","4","5"],"QID110":4,"QID110_DO":["1","2","3","4","5"],"QID118":["4"],"QID118_DO":["1","2","3","4"],"QID185":["2"],"QID185_DO":["1","2","3","4","5"],"QID186":2,"QID186_DO":["1","2"],"QID187":2,"QID187_DO":["1","2"],"QID26":2,"QID26_DO":["1","2"],"QID170":2,"QID170_DO":["1","2"],"QID171":1,"QID171_DO":["5","4","3","2","1"],"QID154_TEXT":";kj","QID218":1,"QID218_DO":["1","2"],"QID28":1,"QID28_DO":["1","2"],"QID127_TEXT":"lk","QID23":["1"],"QID23_DO":["1","2","3","4","5","6"],"QID188":2,"QID188_DO":["1","2"],"QID310_TEXT":"ou","QID312":1,"QID312_DO":["1","2"],"QID313_TEXT":"a","QID314_TEXT":"asdf","QID96":1,"QID96_DO":["1","2","3","4","5"],"QID97":1,"QID97_DO":["1","2","3","4","5"],"QID102":1,"QID102_DO":["1","2","3","4","5"],"QID168":["3"],"QID168_DO":["1","2","3","4","5","6","7","8","9","10"],"QID139":["1"],"QID139_DO":["8","1","2","4","11","12","22","21","10","0"],"QID104":3,"QID104_DO":["5","4","3","2","1"],"QID148":5,"QID148_DO":["1","2","3","4","5"],"QID202":22,"QID202_DO":["20","16","1","19","6","17","12","18","11","15","7","4","14","21","13","9","10","5","8","22","23"],"QID106":5,"QID106_DO":["1","2","3","4","5"],"QID189":1,"QID189_DO":["1","2"],"QID8":[],"QID8_DO":["1","2","3","4"],"QID213":["1"],"QID213_DO":["1","2","4"],"QID190":2,"QID190_DO":["1","2"],"QID204":4,"QID204_DO":["1","4","5","6","7","8","9","10","11","12","13"],"QID316_1_1":324,"QID316_1_4":234,"QID316_1_2":234,"QID316_6_4":234,"QID316_6_2":234,"QID316_DO":["1","2"],"QID103":5,"QID103_DO":["1","2","3","4","5"],"QID95":5,"QID95_DO":["1","2","3","4","5"],"QID99":44,"QID99_DO":["1","2","3","44","5"],"QID98":4,"QID98_DO":["1","2","3","4","5"],"QID217":5,"QID217_DO":["1","2","3","4","5"],"QID101":24,"QID101_DO":["23","24","29","28"],"QID108":5,"QID108_DO":["1","2","3","4","5"],"QID137":["5"],"QID137_DO":["1","3","4","2","5","6","7","8"],"QID138":["5"],"QID138_DO":["1","3","4","2","5","6","11","12","13","14","17"],"QID109":5,"QID109_DO":["1","2","3","4","5"],"QID33":2,"QID33_DO":["1","2"],"QID50":2,"QID50_DO":["1","2"],"QID322":["6"],"QID322_DO":["1","4","5","6","7","8","9","10"],"QID323":2,"QID323_DO":["1","2"],"QID324":5,"QID324_DO":["1","4","5","6"],"QID325":2,"QID325_DO":["1","2"],"QID326":5,"QID326_DO":["1","4","5","6"],"QID327":6,"QID327_DO":["1","4","5","6","7","8"],"QID328":8,"QID328_DO":["1","4","5","6","7","8","9","10"],"QID329":2,"QID329_DO":["1","2"],"QID330_DO":["1","2","4"],"QID331":2,"QID331_DO":["1","2"],"SurveyID":"SV_3q0Wqi06cXPQdE2","Q_TotalDuration":223,"Program Partner":"WF","Program Target":"SMB","Program Department":"Innovations","a_program_id":"a0R1K00000D59rE","a_cohort_id":"0011K00002Y9LOC","a_user_id":"0031K00003EUOi6QAH","Q_URL":"https://aworks.sjc1.q.com/jfe/form","QSEDResponseID":"R_2q8m84s2YQvygki","Course Recommendations":"Thank you for completing your Business Health Assessment Survey.  A customized learning plan has been prepared just for you!  Your Business Health Scorecard and learning materials are available in online.  You will receive updates and reminders from a and your Cohort Coach along the way.","QuickView_URL":"https://qv.walkerinfo.com/?SID=SV_3q0Wqi06cXPQdE2&R=R_2q8m84s2YQvygki","RV_SID":"SV_3q0Wqi06cXPQdE2","QV1":"resultsview.aworks.org/bha/R_2q8m84s2YQvygki","RV2":"resultsview.aworks.org/bha/R_2q8m84s2YQvygki?survey_id=SV_3q0Wqi06cXPQdE2","Introduction to Customer Acquisition":"Watch sessions online or speak with a small business expert about how to develop a customer profile and an acquisition strategy.","Introduction to Customer Relationships":"Course covering the essentials for developing a customer profile and an acquisition strategy.","Introduction to Finances":"Work with a small business expert or browse online for courses on financial management best practices.","Advanced Finances":"Connect with a small business expert or browse online courses on advance business strategies for growth.","Introduction to Business Software":"Course by provider on how to use their tools.","Introduction to Human Resources":"Establishing an HR management structure is important for your business. Connect with a small business expert or browse online courses about employee management (hiring, benefits, etc).","Advanced Marketing Strategy":"Course covering how to develop a marketing strategy for your business.","Introduction to Payment Processing":"Course covering opportunities to expand payment collection avenues.","Introduction to Supplier Inclusion":"Introduction to how to contract with the government, secure necessary licenses, and grow business revenue through contracts/b2b.","Introduction to Web Tools":"Course by provider on how to use their tools.","Business Strengths":"---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------","Financial _1":"Make time to review grant opportunities applicable for your business as a way to fund future business growth.","Financial_3":"To maintain stability of pricing, make a plan to periodically review cost structure and make necessary adjustments to pricing.","Financial_4":"Ensure that your validation analysis reflects the current state of the business by periodically evaluating and making changes to the plan.","Customer_6":"Periodically assess whether all of your marketing channels are yielding the expected results and whether the effort is giving a measurable return.","Operations_3":"Set a schedule to regularly check in with corporate contacts about business contracts to ensure successful execution of deliverable and strength of relationship over time.","Operations_4":"Schedule a meeting with a legal expert at least once a year to make sure that your latest business practices are compliant with all applicable laws and regulations.","Operations_5":"Speak with a legal expert, as necessary, to make sure your business is still up to date on all state and local regulations, as these can change over time.","Operations_8":"Periodically review your business plan to ensure that you are on track to meet your outlined business goals.","Operations_9":"Conduct regular employee satisfaction assessments (can be informal through a quick conversation) to ensure your employees are happy in their roles and prevent turnover.","Operations_10":"Set a plan to periodically evaluate your plan for how the business will function beyond your retirement to make sure it still reflects your desires and current business stage.","Operations_11":"Set aside some time with all relevant parties to evaluate whether your current process for maintaining efficient delivery of products/services is accurate and explore whether there are any areas for increased efficiencies.","Operations_12":"Make sure to conduct a health assessment of all business software to ensure your business data (records, inventory, finances, payroll, HR) is protected. Consider regular password changes and product evaluation to maximize revenue.","Business Opportunities":"---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------","Financial_N2":"Make a habit of paying all debt obligations on time and as promised to build a strong credit score, which can help secure necessary capital in the future.","Financial_N5":"Your lack of a tracking process for profit margins is a potential liability, consider putting in place a tracking process.","Financial_N6":"Explore whether there are any ways for your business to earn recurring or passive income without active labor.","Financial_N8":"Work with an accounting expert to develop up to date business records (tax, bank statements, and accounting books).","Financial_N9":"Evaluate pricing structure to ensure that the business is able to cover all expenses without the need for additional grants or funding sources.","Financial_N10":"Consider working with a CPA (Certified Public Accountant) to ensure your business is compliant with the IRS and maintains up to date business records.","CustomerRelation_N2":"Periodically assess customer demand trends to create predictable production schedules.","CustomerRelation_N3":"Work with a marketing expert to develop a strategic marketing plan that provides a roadmap for marketing efforts that yield valuable results.","CustomerRelation_N4":"Develop a customer feedback survey process to collect insights from customers that help inform business decisions.","Operations_N1":"Explore whether your business is able to afford offering medical insurance/benefits to employees in order to attract better suited candidates for your roles.","Operations_N2":"Explore whether there are opportunities for your business to contract with the government and what licenses/certifications might be necessary.","Complete":"1","QUICKVIEW":"https://qv.com/?SID=SV_3q0Wqi06cXPQdE2&R=R_2q8m84s2YQvygki","Q_DataPolicyViolations":["Email Address"]},"labels":{"status":"IP Address","finished":"True","QID141":"Yes, I consent to the above","QID141_DO":["<strong>Yes</strong>, I consent to the above","<strong>No</strong>, I do not consent to the above"],"QID335_DO":["First Name","Last Name","Title","Email Address","Phone Number","a Account ID"],"QID340":"LiftFund","QID340_DO":["Community Economic Development Fund","LiftFund","Urban League of Philadelphia","Metro Economic Development Corporation","Maryland Capital Enterprises","Corner To Corner","My Sister's Village","GROW Nebraska","Tulsa Economic Development Corporation","Other"],"QID205":"I was not in business in the last calendar year","QID205_DO":["Less than $10,000 ","$10,000 to $24,999 ","$25,000 to $49,999 ","$50,000 to $99,999 ","$100,000 to $249,999 ","$250,000 to $499,000 ","$500,000 to $999,999 ","$1,000,000 or more ","I was not in business in the last calendar year"],"QID206":"$100,000 to $249,999 ","QID206_DO":["Less than $10,000 ","$10,000 to $24,999 ","$25,000 to $49,999 ","$50,000 to $99,999 ","$100,000 to $249,999 ","$250,000 to $499,000 ","$500,000 to $999,999 ","$1,000,000 or more ","I was not in business in the last calendar year"],"QID107":"Neither agree nor disagree","QID107_DO":["Strongly disagree","Somewhat disagree","Neither agree nor disagree","Somewhat agree","Strongly agree"],"QID105":["Online/eCommerce"],"QID105_DO":["Online/eCommerce","Storefront","Multiple product/service offerings","In-person events (e.g. conferences, meet-ups, workshops)","Webinars","Delivery service","Other"],"QID165":["Credit"],"QID165_DO":["Cash","Check","Credit","Debit","Online","Mobile/Contactless","Peer-to-Peer (e.g. Zelle, Venmo, CashApp)","Cryptocurrency (e.g. Bitcoin)","PayPal","Apple Pay","Samsung Pay","Google Pay"],"QID100":"Somewhat disagree","QID100_DO":["Strongly agree","Somewhat agree","Neither agree nor disagree","Somewhat disagree","Strongly disagree"],"QID110":"Somewhat agree","QID110_DO":["Strongly disagree","Somewhat disagree","Neither agree nor disagree","Somewhat agree","Strongly agree"],"QID118":["I prefer not to upload a document"],"QID118_DO":["Income statement","Cash flow statement","Balance sheet","I prefer not to upload a document"],"QID185":["Expenses"],"QID185_DO":["Income","Expenses","Profit Margins","Profits margins for services/products","Demand for services/products"],"QID186":"No","QID186_DO":["Yes","No"],"QID187":"No","QID187_DO":["Yes","No"],"QID26":"No","QID26_DO":["Yes","No"],"QID170":"No","QID170_DO":["Yes","No"],"QID171":"Strongly agree","QID171_DO":["Strongly disagree","Somewhat disagree","Neither agree nor disagree","Somewhat agree","Strongly agree"],"QID218":"Yes","QID218_DO":["Yes","No"],"QID28":"Yes","QID28_DO":["Yes","No"],"QID23":["Hourly Pricing (Time and expense, invoice for all expenses plus hourly rate. E.g. a moving company might charge a base rate for mileage and labor expenses and bill for each hour to complete the job)"],"QID23_DO":["<strong>Hourly Pricing</strong> (Time and expense, invoice for all expenses plus hourly rate. E.g. a moving company might charge a base rate for mileage and labor expenses and bill for each hour to complete the job)","<strong>Cost-Plus Pricing</strong> (Setting price based on costs associated plus a percent for profit. E.g. the price a bakery sets for a cake would sum the cost of ingredients plus an amount for profit)","<strong>Value-Based Pricing</strong> (Setting price based on customer perceived value. E.g. a television station may sell commercial airtime at different rates as different times could have different values to clients)","<strong>Fixed Pricing</strong> (Setting price for service offered regardless of the time to complete. E.g. a salon may charge a set price for a haircut regardless of the time it takes to complete.)","<strong>Performance-Based Pricing</strong> (Setting price based on the performance of the product or service you deliver. E.g. a SEO expert may charge a fee for each new website customer)","Other"],"QID188":"No","QID188_DO":["Yes","No"],"QID312":"Yes","QID312_DO":["Yes","No"],"QID96":"Delightful","QID96_DO":["Delightful","Good","Average","Poor","Terrible"],"QID97":"Strongly disagree","QID97_DO":["Strongly disagree","Somewhat disagree","Neither agree nor disagree","Somewhat agree","Strongly agree"],"QID102":"Strongly disagree","QID102_DO":["Strongly disagree","Somewhat disagree","Neither agree nor disagree","Somewhat agree","Strongly agree"],"QID168":["Website/blog"],"QID168_DO":["Social media","Email marketing","Website/blog","Content marketing","Word of mouth","Cold Calling","TV","Radio","Other","None of the above"],"QID139":["Facebook"],"QID139_DO":["Pinterest","Facebook","Instagram","Twitter","TikTok","Snapchat","Hootsuite","Google Analytics","Other","None of the above"],"QID104":"Maintained production","QID104_DO":["Significantly increased production","Increased production","Maintained production","Decreased production","Significantly decreased production"],"QID148":"Strongly agree","QID148_DO":["Strongly disagree","Somewhat disagree","Neither agree nor disagree","Somewhat agree","Strongly agree"],"QID202":"Other Services (except Public Administration) ","QID202_DO":["Accommodation and Food Services ","Administrative and Support and Waste Management and Remediation Services ","Agriculture, Forestry, Fishing, and Hunting","Arts, Entertainment, and Recreation ","Construction ","Educational Services ","Finance and Insurance ","Health Care and Social Assistance ","Information ","Management of Companies and Enterprises ","Manufacturing ","Mining ","Professional, Scientific and Technical Services ","Public Administration ","Real Estate Rental and Leasing ","Retail Trade ","Transportation and Warehousing ","Utilities ","Wholesale trade ","Other Services (except Public Administration) ","Other (please specify below)"],"QID106":"Strongly agree","QID106_DO":["Strongly disagree","Somewhat disagree","Neither agree nor disagree","Somewhat agree","Strongly agree"],"QID189":"Yes","QID189_DO":["Yes","No"],"QID8":[],"QID8_DO":["Federal","State","Local","None of the above"],"QID213":["Private Corporations"],"QID213_DO":["Private Corporations","Anchor Institutions","None of the above"],"QID190":"No","QID190_DO":["Yes","No"],"QID204":"2 to 4 ","QID204_DO":["1 ","2 to 4 ","5 to 9 ","10 to 19 ","20 to 49 ","50 to 99 ","100 to 249 ","250 to 499 ","500 to 999 ","1,000 to 1,499 ","1,500 or more "],"QID316_DO":["<strong>Full Time Employees</strong>","<strong>Part Time Employees</strong>"],"QID103":"Strongly agree","QID103_DO":["Strongly disagree","Somewhat disagree","Neither agree nor disagree","Somewhat agree","Strongly agree"],"QID95":"Strongly agree","QID95_DO":["Strongly disagree","Somewhat disagree","Neither agree nor disagree","Somewhat agree","Strongly agree"],"QID99":"Somewhat agree","QID99_DO":["Strongly disagree","Somewhat disagree","Neither agree nor disagree","Somewhat agree","Strongly agree"],"QID98":"Somewhat agree","QID98_DO":["Strongly disagree","Somewhat disagree","Neither agree nor disagree","Somewhat agree","Strongly agree"],"QID217":"Much less","QID217_DO":["Much more","Somewhat more","About the same","Somewhat less","Much less"],"QID101":"No","QID101_DO":["Yes","No","No, but we plan to offer","We used to, but currently do not"],"QID108":"Strongly agree","QID108_DO":["Strongly disagree","Somewhat disagree","Neither agree nor disagree","Somewhat agree","Strongly agree"],"QID137":["FreshBooks"],"QID137_DO":["QuickBooks/Intuit","ADP","Gusto","Monday","FreshBooks","Bench","Other","None of the above"],"QID138":["Web.com"],"QID138_DO":["WiX","SquareSpace","WordPress","HostGator","Web.com","AWS","Adobe","Azure","GoDaddy","Other","None of the above"],"QID109":"Strongly agree","QID109_DO":["Strongly disagree","Somewhat disagree","Neither agree nor disagree","Somewhat agree","Strongly agree"],"QID33":"No","QID33_DO":["Yes","No"],"QID50":"No","QID50_DO":["Yes","No"],"QID322":["Asian "],"QID322_DO":["White ","Black or African American ","American Indian or Alaska Native ","Asian ","Native Hawaiian or Other Pacific Islander ","2 or more of the above ","I prefer to self-describe (please describe below)","I prefer to abstain"],"QID323":"No","QID323_DO":["Yes","No"],"QID324":"Non-Binary OR gender-fluid OR agender ","QID324_DO":["Male (including transgender men) ","Female (including transgender women) ","Non-Binary OR gender-fluid OR agender ","I prefer to self-describe (please describe below)"],"QID325":"No","QID325_DO":["Yes","No"],"QID326":"Heterosexual or Straight","QID326_DO":["Bisexual","Gay or Lesbian","Heterosexual or Straight","I prefer to self-describe (please describe below)"],"QID327":"45 to 54 ","QID327_DO":["Under 25 ","25 to 34 ","35 to 44 ","45 to 54 ","55 to 64 ","65 or older"],"QID328":"Master’s degree ","QID328_DO":["Less than high school ","High school graduate ","Some college, no degree ","2-year degree ","4-year degree ","Master’s degree ","Professional degree (e.g. M.D. or J.D.) ","Doctorate "],"QID329":"No","QID329_DO":["Yes","No"],"QID330_DO":["Yes","No","I don't know"],"QID331":"No","QID331_DO":["Yes","No"]},"displayedFields":["QID190","QID127_TEXT","QID107","QID137_7_TEXT","QID108","QID109","QID313_TEXT","QID103","QID104","QID148","QID105","QID106","QID187","QID188","QID100","QID168_9_TEXT","QID326_6_TEXT","QID189","QID101","QID33","QID102","QID324_6_TEXT","QID185","QID141","QID186","QID340","QID340_10_TEXT","QID316_6_1","QID316_6_2","QID316_6_4","QID8","QID139_14_TEXT","QID118","QID312","QID23_6_TEXT","QID110","QID170","QID171","QID202_23_TEXT","QID322_9_TEXT","QID335_4","QID335_5","QID50","QID206","QID327","QID328","QID329","QID202","QID323","QID310_TEXT","QID324","QID204","QID325","QID205","QID326","QID165","QID168","QID322","QID99","QID98","QID97","QID96","QID95","QID316_1_1","QID316_1_2","QID335_22","QID316_1_4","QID335_23","QID314_TEXT","QID28","QID26","QID138_14_TEXT","QID217","QID218","QID213","QID137","QID154_TEXT","QID335_6","QID138","QID335_7","QID139","QID330","QID105_28_TEXT","QID331","QID23"],"displayedValues":{"QID190":[1,2],"QID107":[1,2,3,4,5],"QID108":[1,2,3,4,5],"QID109":[1,2,3,4,5],"QID103":[1,2,3,4,5],"QID104":[5,4,3,2,1],"QID148":[1,2,3,4,5],"QID105":["23","24","25","26","27","30","28"],"QID106":[1,2,3,4,5],"QID187":[1,2],"QID188":[1,2],"QID100":[1,2,3,4,5],"QID189":[1,2],"QID101":[23,24,29,28],"QID33":[1,2],"QID102":[1,2,3,4,5],"QID185":["1","2","3","4","5"],"QID141":[1,2],"QID186":[1,2],"QID340":[1,2,3,4,5,6,7,8,9,10],"QID8":["1","2","3"],"QID118":["1","2","3","4"],"QID312":[1,2],"QID110":[1,2,3,4,5],"QID170":[1,2],"QID171":[5,4,3,2,1],"QID50":[1,2],"QID206":[1,4,5,6,7,8,9,10,11],"QID327":[1,4,5,6,7,8],"QID328":[1,4,5,6,7,8,9,10],"QID329":[1,2],"QID202":[20,16,1,19,6,17,12,18,11,15,7,4,14,21,13,9,10,5,8,22,23],"QID323":[1,2],"QID324":[1,4,5,6],"QID204":[1,4,5,6,7,8,9,10,11,12,13],"QID325":[1,2],"QID205":[1,4,5,6,7,8,9,10,11],"QID326":[1,4,5,6],"QID165":["1","2","3","4","5","6","7","8","9","10","11","12"],"QID168":["1","2","3","4","5","6","7","8","9"],"QID322":["1","4","5","6","7","8","9"],"QID99":[1,2,3,44,5],"QID98":[1,2,3,4,5],"QID97":[1,2,3,4,5],"QID96":[1,2,3,4,5],"QID95":[1,2,3,4,5],"QID28":[1,2],"QID26":[1,2],"QID217":[1,2,3,4,5],"QID218":[1,2],"QID213":["1","2"],"QID137":["1","3","4","2","5","6","7"],"QID138":["1","3","4","2","5","6","11","12","13","14"],"QID139":["8","1","2","4","11","12","22","21","10"],"QID330":[1,2],"QID331":[1,2],"QID23":["1","2","3","4","5","6"]}},"meta":{"requestId":"60b6c3d1-b9d9-4980-a543-e3ef71dd66b8","httpStatus":"200 - OK"}}
2
  • 3
    You'll need to expose the JSON for us to give you more guidance
    – cropredy
    Nov 24, 2022 at 0:02
  • @cropredy ok, I've added it as an edit.
    – AMtrying
    Nov 25, 2022 at 15:42

1 Answer 1

1

File processing is a complicated topic in any language. Each file has specific protocols that favor some characteristic. For example, movie files often include metadata that makes it easy to seek to a specific frame or time in the movie, and image files often have properties to make it possible to know how much memory to allocate to the rendered image. JSON follows specific rules, and those rules can't be violated if it is valid JSON. This means that, at minimum, the entire JSON string has to be parsed for correctness.

However, if you don't need all that extra data, simply don't use it. The JSON parser doesn't care about extra data unless it's in strict mode. It's perfectly fine to have a class that has just the information you want. I'll show a simple example here.

class Demo {
    public String message;
}
Demo x = (Demo)JSON.deserialize('{"message":"Hello World","garbage":"Other Data"}', Demo.class);
System.debug(x.message);

Here, I get the message "Hello World", while "garbage" is simply ignored. The JSON must still be valid, but it's code I didn't have to write since I didn't care. This isn't always possible, though; if your data is organized a certain way, you may very well be forced to create a design that includes data you don't care about. In most cases, that's probably okay, since most requests aren't terribly big to begin with.

The caveat here is simply that without knowing what your JSON looks like, it's impossible to tell you how much data you "need" to process. You might have a design like this, or you might need something radically more complex. That said, you can certainly try to pare down the amount of code you need to write, though I wouldn't recommend wasting too much time doing so. JSON2Apex is a favorite tool of mine, it gets the job done in a timely manner most of the time.

1
  • Thank you! This definitely pointed me in the right direction. I ended up 'beautifying' the json and used " Util_JsonParser parJSON = Util_JSONParser.createParser(json); Object result = parJSON.get('result').Value; String res = String.ValueOf(result);" To get deeper into the json, eventually retrieving the value I needed which was just a step or two deeper.
    – AMtrying
    Nov 25, 2022 at 20:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.