Explore Courses Blog Tutorials Interview Questions
0 votes
in Salesforce by (11.9k points)

Can I parse Multi-Level nested JSON structure in APEX Salesforce, like we do in Java with GSON and Jackson libraries?










I have already explored this.

Parsing JSON in Apex Salesforce

But I want a generic solution which will parse any JSON to the required Apex Object.

1 Answer

0 votes
by (32.1k points)

You use the serialize/deserialize methods of the JSON class in Apex:

You'll want to create an Apex class based on your input JSON, but there's even a handy tool to do it:

Regrettably, you're bounded by the depth of the Apex classes. I think after key4 in your example, you're back to parsing it manually.

One thing to consider is building a partial model in Apex, then hydrating any deeper nested objects you need using the parser.

To learn in-depth about Workflow in Salesforce, sign up for an industry based Salesforce Certification.

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.5k answers


108k users

Browse Categories