在 JsnoToApex 类中,我尝试从https://openweathermap.org/current获取 JSON 文件。当我尝试解析 JSON.CreateParses 时出现以下错误: Illegal assignment from System.JSONParser to JsonParser
我尝试制作显示伦敦天气的 API。
公共共享类 JsonToApex {
@future(callout=true)
public static void parseJSONResponse() {
String resp;
Http httpProtocol = new Http();
// Create HTTP request to send.
HttpRequest request = new HttpRequest();
// Set the endpoint URL.
String endpoint = 'https://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=b6907d289e10d714a6e88b30761fae22';
request.setEndPoint(endpoint);
// Set the HTTP verb to GET.
request.setMethod('GET');
// Send the HTTP request and get the response.
// The response is in JSON format.
HttpResponse response = httpProtocol.send(request);
resp = response.getBody();
JSONParser parser = JSON.createParser(resp);
JsonMapper response = (JsonMapper) System.JSON.deserialize(res.getBody(), JsonMapper.class);
}
}
我希望获得 Json 文件,并在未来使用https://json2apex.herokuapp.com/映射它