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
Diwakar Rajput 1Diwakar Rajput 1 

how to parse JSON to apex

Below is the part of my class. these are the wrapper class.
 public class ASMWrapper{
        @auraEnabled public User userObj{get;set;}
        @auraEnabled public String RoleName{get;set;}
        @auraEnabled lookUpWrapper selItem{get;set;}
    }
    public class lookUpWrapper{
        public String objName {get;set;}
        public String text{get;set;}
        public String val{get;set;}
        public Object ObjRecord{get;set;}
    }

Below ti the method which convert the json to string.

 public class ASMWrapper{
        @auraEnabled public User userObj{get;set;}
        @auraEnabled public String RoleName{get;set;}
        @auraEnabled lookUpWrapper selItem{get;set;}
    }
    public class lookUpWrapper{
        public String objName {get;set;}
        public String text{get;set;}
        public String val{get;set;}
        public Object ObjRecord{get;set;}
    }

this method is getting the JSON. please help me parse it.

public static void  newAccRecord(String asmHierarchy){
        system.debug('string JSON '+asmHierarchy);
        System.debug('jason der' + JSON.deserializeUntyped(asmHierarchy));
        /*if(asmHierarchy.size() >0){
            for(object obj : asmHierarchy){
                system.debug('obj '+obj);
                //ASMWrapper asm = (ASMWrapper)obj;
                //system.debug('User ==> '+asm.asmObj.userObj);
            }
            System.debug(' ASMWrapper DONE @@@ '+asmHierarchy);
            System.debug('size of role '+asmHierarchy.size());
        }*/
       
    }
ASIF ALIASIF ALI
For parsing any json, First convert it into object and after that access the records according the key inside the object,