How can i deserialize a json string into a list of wrapper in apex ? here is my code :

    public class PageLayoutErrorMsg{
      public String errorId{get;Set;}
      public String errorType{get;Set;}
      public String Message{get;Set;}       
    LIST<PageLayoutErrorMsg> pageErrors = new LIST<PageLayoutErrorMsg>();
    pageErrors = (LIST<PageLayoutErrorMsg>) JSON.deserialize(c.TECH_DisplayedErrorJSON__c,(LIST<PageLayoutErrorMsg>).class);    

I am obtaining the following syntax error : unexpected token list Have anyone came across this problem?


Try this:

pageErrors = (List<PageLayoutErrorMsg>) JSON.deserializeUntyped(c.TECH_DisplayedErrorJSON__c); 


pageErrors = (List<PageLayoutErrorMsg>) JSON.deserialize(c.TECH_DisplayedErrorJSON__c,List<PageLayoutErrorMsg>.class); 

Assuming that c.TECH_DisplayedErrorJSON__c has correct json.

  • For the list type,I should write : LIST<PageLayoutErrorMsg>.class and not (LIST<PageLayoutErrorMsg>).class – vanessen Aug 20 '15 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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