【发布时间】:2019-11-03 07:34:41
【问题描述】:
这是我对 API 的 POST 请求
ResponseEntity<String> result = rt.exchange(url, HttpMethod.POST, httpEntity, String.class);
我得到的回应如下
{
"headers": {
"Cache-Control": [
"no-store"
],
"Content-Type": [
"application/json;charset=UTF-8"
],
"Date": [
"Thu, 20 Jun 2019 12:50:08 GMT"
],
"Pragma": [
"no-cache"
],
"Server": [
"val"
],
"X-Content-Type-Options": [
"nosniff"
],
"X-Frame-Options": [
"DENY"
],
"X-Xss-Protection": [
"1; mode=block"
],
"Content-Length": [
"331"
]
},
"body": {
"access_token": "token_value,
"scope": "KYC",
"token_type": "bearer",
"expires_in": 49900,
"jti": "jti_val"
},
"statusCode": "OK",
"statusCodeValue": 200
}
我需要提取 access_token,scope,token_type,statusCodeValue
那么我的 POJO 类的结构应该是什么来映射响应?或者我如何从 JSON 中获取这些字段的值?
ResponseEntity<PojoClass> result = rt.exchange(url, HttpMethod.POST, httpEntity, PojoClass.class);
【问题讨论】:
标签: json spring spring-boot