-2
I am unable to pass the value of the JSON string to an entity (OBJECT).
I’ve already managed to receive JSON, and code 200 success. But I can’t put that value on the object (Deserialization).
if (response.statusCode == ConversorConstantsAPI.STATUS_CODE.SUCCESS) {
// Deserialization
Gson gson = new Gson();
DolarDia dolarDia = gson.fromJson(response.json, DolarDia.class);
//sponse.setResult(new Gson().fromJson(response.json, DolarDia.class));
String line = "";
result.setResult(dolarDia);
Dolardia class
public class DolarDia {
public String mContext;
public DolarDiaValores dolarDiaValores;
}
Class Values Dolar
public class DolarDia {
public String mContext;
public DolarDiaValores dolarDiaValores;
}
Value received:
response.json {"@odata.context":"https://was-p.bcnet.bcb.gov.br/olinda/servico/PTAX/versao/v1/odata$metadata#_CotacaoDolarDia(cotacaoCompra,cotacaoVenda,dataHoraCotacao)","value":[{"cotacaoCompra":3.96440,"cotacaoVenda":3.96500,"dataHoraCotacao":"2019-05-02 13:10:38.779"}]}
response = {APIResponse@4408}
json = "{"@odata.context":"https://was-p.bcnet.bcb.gov.br/olinda/servico/PTAX/versao/v1/odata$metadata#_CotacaoDolarDia(cotacaoCompra,cotacaoVenda,dataHoraCotacao)","value":[{"cotacaoCompra":3.96440,"cotacaoVenda":3.96500,"dataHoraCotacao":"2019-05-02 13:10:38.779"}]}"
statusCode = 200
shadow$_klass_ = {Class@4312}
shadow$_monitor_ = -1901606490