【发布时间】:2020-09-25 19:02:34
【问题描述】:
我正在调用 Google Directory API,并且只需要它返回的几个字段。我对 Java/Spring 相当陌生,所以我试图找出解决这个问题的最佳方法。我提出这样的要求:
restTemplate.exchange(url, HttpMethod.GET, req, Object, userKey);
我目前将它作为一个对象,但不确定这是否正确。当我只需要几个字段时,我不想映射出它返回的非常大的对象。有没有办法访问这些字段,phone, organizations, locations?
res.getClass().getField("phones") 对我不起作用。
出于目的,我们可以考虑对象的形状:
{
phones: [type: String, number: String],
organizations: [title: String],
locations: [buildingId: String]
}
【问题讨论】:
标签: java spring google-directory-api