search

Home  >  Q&A  >  body text

android - Retrofit网络请求库请求得到字符串问题

请求得到只是一个字符串

但是返回结果却多了两个双引号,应该怎样解决啊
我用抓包返回结果是正确的

迷茫迷茫2772 days ago419

reply all(1)I'll reply

  • 怪我咯

    怪我咯2017-04-17 17:45:03

    This is how I get the String directly

    Get retrofit instance

        public static Retrofit GetStringRetrofit(){
            Retrofit retrofit = new Retrofit.Builder()
                    .client(okHttpClientWithBaiduHeader)
                    .baseUrl(AppConfig.HEFENG_BASE_URL)
                    .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                    .addConverterFactory(ScalarsConverterFactory.create()) //这里不是GsonConvertFactory了
                    .build();
            return retrofit;
        }

    The interface can receive String directly

    public interface GetHeWeather {
    
        @GET("weather")
        Observable<String> getHeWeather(@Query("city") String city, @Query("key") String key);
    }

    The following is the log

    If it doesn’t work, just use subString. . .

    reply
    0
  • Cancelreply