有奖捉虫:云通信与企业服务文档专题,速来> HOT
Response.json 将 Response.body 反序列化为 json。
json(): any

返回

类型
描述
any
返回代表 Response.body 的对象

样例

import http from 'pts/http';

export default function () {
const req = {
method: 'post',
url: 'http://httpbin.org/post',
headers: { 'Content-Type': 'application/json' },
query: { a: '1' },
body: { user_id: '12345' },
};
const resp = http.do(req);

console.log(resp.json()); // [Object object]
console.log(resp.json().args.a); // 1
console.log(resp.json().json.user_id); // 12345
}