json到带有输入参数的字段的对象映射器

时间:2018-12-05 05:58:23

标签: json rest jackson pojo mapper

             `String strJson = EntityUtils.toString(response.getEntity());
               JSONObject exchangeRates = new JSONObject(strJson);`

exchangeRates的结果为exchangeRates: {"terms":"https://shortenstr.co/terms","success":true,"privacy":"https://shortenstr.co/privacy","source":"USD","timestamp":1543984146,"quotes":{"USDEUR":0.882705}}

我用过:      ObjectMapper objectMapper = new ObjectMapper(); Currency currency = objectMapper.readValue(strJson, Currency.class);

`公共类货币{

@JsonIgnore
private Boolean success;
private String terms;
private String privacy;
private Long timestamp;
private String source;
private Quotes quotes;
...}  `


public class Quotes {
private String curr;
private Double rate;

如何使用地图代替报价? 请如何将JSONObject转换为POJO? USDEUR由输入参数组成。谢谢。

0 个答案:

没有答案