I am getting an error while converting the response from JSON to Apex class.
Invalid conversion from runtime type MapAPIDemo.resourceSets to List<MapAPIDemo.resourceSets>
Here is the code below
Apex Code
public with sharing class MapAPIDemo {
public list<resourceSets> listresourceSet{get;set;}
public Integer statusCode{get;set;}
public String copyright{get;set;}
public String statusDescription{get;set;}
public String brandLogoUri{get;set;}
public String traceId{get;set;}
public String authenticationResultCode{get;set;}
public static void getPostalCodeDetails(String postalCode){
HttpRequest request = new HttpRequest();
String endPoint = 'http://dev.virtualearth.net/REST/v1/Locations?postalCode=';
endPoint += postalCode;
endPoint += '&key=';
endPoint += SYSTEM.Label.BING_API;
request.setEndPoint(endPoint);
request.setMethod('GET');
Http http = new Http();
HttpResponse response = http.send(request);
if(response.getStatusCode() == 200){
System.debug('Code Results=====>'+response.getStatus());
String responseBody = response.getBody();
//List<MapAPIDemo.resourceSets> lstResource = (List<MapAPIDemo.resourceSets>) JSON.deserialize(response.getBody(),MapAPIDemo.resourceSets.class);
//system.debug('resourceSets====>'+lstResource);
}
}
public class resourceSets{
public list<resources> resources{get;set;}
public Integer estimatedTotal{get;set;}
}
public class resources{
public String entityType{get;set;}
public String confidence{get;set;}
public point point{get;set;}
public address address{get;set;}
public String name{get;set;}
public list<geocodePoints> geocodePoints{get;set;}
public list<String> bbox{get;set;}
public list<String> matchCodes{get;set;}
public String locType{get;set;}
}
public class point{
public list<String> coordinates{get;set;}
public String type{get;set;}
}
public class geocodePoints{
public String type{get;set;}
public String calculationMethod{get;set;}
public list<String> usageTypes{get;set;}
public list<String> coordinates{get;set;}
}
public class address{
public String postalCode{get;set;}
public String countryRegion{get;set;}
public String formattedAddress{get;set;}
public String adminDistrict2{get;set;}
public String locality{get;set;}
public String adminDistrict{get;set;}
}
}
Thanks for the help,