You may follow the code snippet below. 1. Define the following class based on HTTP response to this class:
2. Use the following line to deserialize http reponse body.JSONClass myJSONInstance = (JSONClass)JSON.deserialize(response.getBody(), JSONClass.class);3. Build Proxy_Server__c object data and insert. the reponse does not return map or list at all, not sure why you tried to deserialize http reponse body to map and list. Proxy_Server__c proxyIpList = new Proxy_Server__c(); proxyIpList.Name = myJSONInstance .country'; proxyIpList.IP_Address__c = myJSONInstance.ip; proxyIpList.Port__c = myJSONInstance.port; proxyIpList.Last_Update__c = myJSONInstance.lastTested; proxyIpList.Proxy_Level__c = myJSONInstance.anonymity; proxyIpList.Provider__c = 'Get Proxy'; proxyIpList.Proxy_Provider__c = myJSONInstance.proxyServerId; insert proxyIpList;public with sharing class JSONClass {
public String ip {get;set;}
public Integer port {get;set;}
public String protocol {get;set;}
public String anonymity {get;set;}
public String lastTested {get;set;}
public Boolean allowsRefererHeader {get;set;}
public Boolean allowsUserAgentHeader {get;set;}
public Boolean allowsCustomHeaders {get;set;}
public Boolean allowsCookies {get;set;}
public Boolean allowsPost {get;set;}
public Boolean allowsHttps {get;set;}
public String country {get;set;}
public String connectTime {get;set;}
public String downloadSpeed {get;set;}
public String secondsToFirstByte {get;set;}
public String uptime {get;set;}
}
error
Close
2 answers