Salesforce:使用REST标注和JSON2Apex

时间:2017-10-05 07:00:23

标签: json parsing salesforce apex

希望有人能帮助我。

我对顶点代码(以前是系统管理员)相对较新 - 对于我可能错过的任何简单的事情,真诚的道歉!我正在尝试使用JSON2APEX工具将json从REST标注解析到我的开发组织。我的课程如下:

public class JSON2Apex {
    public Boolean success;
    public String message;
    public List<Result> result;

public class Result {
    public String MarketCurrency;
    public String BaseCurrency;
    public String MarketCurrencyLong;
    public String BaseCurrencyLong;
    public Double MinTradeSize;
    public String MarketName;
    public Boolean IsActive;
    public String Created;
    public Object Notice;
    public Object IsSponsored;
    public String LogoUrl;
}

public static JSON2Apex parse(String json) {
    return (JSON2Apex) System.JSON.deserialize(json, JSON2Apex.class);
}
}

Public Class GetBittrexCoins{
public static HttpResponse makeGetCallout(){
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://bittrex.com/api/v1.1/public/getmarkets');
request.setMethod('GET');
HttpResponse response = http.send(request);
// If the request is successful, parse the JSON response.
if (response.getStatusCode() == 200) {
JSON2Apex p = JSON2Apex.parse(response.getBody());
System.debug(p);
}
return response;
}
}

我的System.debug中没有出现json正文 - 所以我显然做错了。任何指针都将非常感谢!

由于

0 个答案:

没有答案