如何在OkHttp Response中更改正文?
2022-09-01 19:53:01
我正在使用改造。要捕获响应,我正在使用拦截器:
OkHttpClient okHttpClient = new OkHttpClient();
okHttpClient.interceptors().add(myinterceptor);
这是拦截器的代码:
new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
Response response = chain.proceed(request);
if (path.equals("/user")){
String stringJson = response.body().string();
JSONObject jsonObject = new JSONObject(stringJson);
jsonObject.put("key",1);
//here I need to set this new json to response and then return this response
如何在OkHttp Response中更改正文?