Cześć.
Mam takie klasy:
package com.example.demo;
import java.util.List;
public class Table
{
private String table;
private String no;
private String effectiveDate;
private List<Rate> rates;
public Table()
{
}
public Table(String table, String no, String effectiveDate, List<Rate> rates)
{
this.table = table;
this.no = no;
this.effectiveDate = effectiveDate;
this.rates = rates;
}
//gettery settery
}
package com.example.demo;
public class Rate
{
private String currency;
private String code;
private double mid;
public Rate()
{
}
public Rate(String currency, String code, double mid)
{
this.currency = currency;
this.code = code;
this.mid = mid;
}
//gettery settery
}
oraz taki restkontroller:
package com.example.demo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
@RestController
public class MyController
{
@RequestMapping("/")
void method()
{
RestTemplate restTemplate = new RestTemplate();
Table table = restTemplate.getForObject("http://api.nbp.pl/api/exchangerates/rates/A/THB/", Table.class);
System.out.println(table);
}
}
To wszystko zwraca coś takiego w konsoli:
Tabela:A
No:null
EffectiveDate:null
Rates:[Currency:null
Code:null
Mid:0.1291]
No i moje pytanie brzmi dlaczego niektóre wartości są nullami?