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
S S MalikS S Malik 

System.JSONException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at input location [1,2]

Hi Developers
I am facing this error
Please help me to solve this problem and my code are
Class# consolewrap 
public class consolewrap {

public String class_id{get;set;}

public String class_time{get;set;}

public String tutor_id{get;set;}

public String tutor_name{get;set;}

public String tutor_email{get;set;} 

public String tutor_phone{get;set;}

}

Class # Calloutcontroller 
public class Calloutcontroller {

public List<consolewrap> ConsoleWrapperList{get;set;}

public List<consolewrap> getperformcallout(){

ConsoleWrapperList = new List<consolewrap>();

HttpRequest req = new HttpRequest();

HttpResponse res = new HttpResponse();

Http http = new Http();

req.setEndpoint('http://www.itutorindia.com/angularjs/api/smallWidget/tutorHourSalesForce');

req.setMethod('GET');

res = http.send(req);

if(res.getstatusCode() == 200 && res.getbody() != null){

ConsoleWrapperList=(List<consolewrap>)json.deserialize(res.getbody(),List<consolewrap>.class);
}
return consolewrapperlist;
}
}

VF PAGE #
<apex:page controller="Calloutcontroller" title="JSON table" >
<apex:form > <apex:pageBlock >
<apex:pageBlockTable value="{!performcallout}" var="wrap">
<apex:column headerValue="class id" value="{!wrap.class_id}"/>
<apex:column headerValue="class time" value="{!wrap.class_time}"/>
<apex:column headerValue="tutor id" value="{!wrap.tutor_id}"/>
<apex:column headerValue="tutor name" value="{!wrap.tutor_name}"/>
<apex:column headerValue="tutor email" value="{!wrap.tutor_email}"/>
<apex:column headerValue="tutor phone" value="{!wrap.tutor_phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

I had made the remote site also
Best Answer chosen by S S Malik
S S MalikS S Malik
public class Calloutcontroller {
public Calloutcontroller(ApexPages.StandardController controller) {
    }
public List<consolewrap> ConsoleWrapperList{get;set;}
public List<consolewrap> getperformcallout(){
ConsoleWrapperList = new List<consolewrap>();
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
req.setEndpoint('http://www.itutorindia.com/angularjs/api/smallWidget/tutorHourSalesForce');
req.setMethod('GET');
req.setHeader('Content-Type', 'application/json');
req.setHeader('Accept','application/json');
res = http.send(req);
if(res.getstatusCode() == 200 && res.getbody() != null){
system.debug('Response body result is+++: ' + res.getBody());
ConsoleWrapperList=(List<consolewrap>)json.deserialize(res.getbody(),List<consolewrap>.class);
}
return ConsoleWrapperList;
}
}

All Answers

SandhyaSandhya (Salesforce Developers) 
Hi,

Please refer below link for a similar issue.

http://salesforce.stackexchange.com/questions/48755/getting-error-while-deserialize
 
If this helps you please mark it as solved.

Thanks and Regards
Sandhya
S S MalikS S Malik
This Link i have already referred but not solving my problem

Thanks for respond Sandhya
Jim JamJim Jam
Have you debugged .. res.getbody() ? What string is your callout returning ?
Tugce SirinTugce Sirin
Problem is that your response is either is not a valid JSON or has a char that is not encoded properly. You need to write 
if(res.getstatusCode() == 200 && res.getbody() != null){
system.debug("Response: " + res.getBody());
ConsoleWrapperList=(List<consolewrap>)json.deserialize(res.getbody(),List<consolewrap>.class);
}
This way you can see your response body and if it has wrong JSON formatting or unexpected character you can inform http://www.itutorindia.com/angularjs/api/smallWidget/tutorHourSalesForce about problem so they fix the return value or you should parse response in a different way. 
S S MalikS S Malik
public class Calloutcontroller {
public Calloutcontroller(ApexPages.StandardController controller) {
    }
public List<consolewrap> ConsoleWrapperList{get;set;}
public List<consolewrap> getperformcallout(){
ConsoleWrapperList = new List<consolewrap>();
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
req.setEndpoint('http://www.itutorindia.com/angularjs/api/smallWidget/tutorHourSalesForce');
req.setMethod('GET');
req.setHeader('Content-Type', 'application/json');
req.setHeader('Accept','application/json');
res = http.send(req);
if(res.getstatusCode() == 200 && res.getbody() != null){
system.debug('Response body result is+++: ' + res.getBody());
ConsoleWrapperList=(List<consolewrap>)json.deserialize(res.getbody(),List<consolewrap>.class);
}
return ConsoleWrapperList;
}
}
This was selected as the best answer
venkatasubbarao Emani 9venkatasubbarao Emani 9
Iam getting same error ,please guide me ,if now any thing