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
rupesh ranjanrupesh ranjan 

Handling error escaped using backslash to be included in string

System.JSONException: Illegal unquoted character ((CTRL-CHAR, code 13)): has to be escaped using backslash to be included in string value at [line:1, column:215] 

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\WraPPER Class///////////////////////////////////////////

public class demomailsentwrap {
public String TotalViewCount{get;set;}   
public String echo{get;set;}  
public String TotalRecords{get;set;}    
public String TotalDisplayRecords{get;set;}   
public List<GroupData> GroupData{get;set;}  
public class GroupData 
{        
public String ID;        
public String Title;        
public String CompanyName;        
public String SessionTitle;        
public String ViewedDate;        
public String DurationStr;        
public String location;        
public String IsVirtualContact;       
public String Groupcontact;        
public String name;        
public String email;    
}     
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\APEX\\\\\\\\\\\\\\\\\\\\\\\
public class demomailsent{
    public List<demomailsentwrap> ConsoleWrapperList{get;set;} 
     public List<demomailsentwrap> getperformcallout(){
      ConsoleWrapperList = new List<demomailsentwrap>();
       HttpRequest req = new HttpRequest(); 
       HttpResponse res = new HttpResponse();
        Http http = new Http(); 
        req.setEndpoint('http://webapi.demomail.net/test/DemomailSent.js'); 
        req.setMethod('GET');
        //req.setHeader('Authorization', 'OAuth '+UserInfo.getSessionId());
        res = http.send(req);
         //System.assert(false,res.getBody()+'******');
       
        
        if(res.getstatusCode() == 200 && res.getbody() != null)
          { 
         ConsoleWrapperList=(List<demomailsentwrap>)System.JSON.deserialize(res.getbody(),List<demomailsentwrap>.class); 
          //System.debug('Response Checking Engine: '+ res.getBody());
          }
            return consolewrapperlist; 
            
          }
          
     }

 
Best Answer chosen by rupesh ranjan
Marek Kosar_Marek Kosar_
Hi Rupes,
you have to get rid of some `illegal characters`, which can't be parsed.
This should help:
String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r','');
ConsoleWrapperList=(List<demomailsentwrap>)System.JSON.deserialize(replaceIllegal,List<demomailsentwrap>.class);

Marek
 

All Answers

Marek Kosar_Marek Kosar_
Hi Rupes,
you have to get rid of some `illegal characters`, which can't be parsed.
This should help:
String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r','');
ConsoleWrapperList=(List<demomailsentwrap>)System.JSON.deserialize(replaceIllegal,List<demomailsentwrap>.class);

Marek
 
This was selected as the best answer
rupesh ranjanrupesh ranjan
Hey Marek
thank you so much :)
Woking fine.