You need to sign in to do that
Don't have an account?
Diwakar 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());
}*/
}
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 ALI
For parsing any json, First convert it into object and after that access the records according the key inside the object,