如何使用 Retrofit2 和 Okhttp3 禁用 URL 编码

Htm*_*sin 5 android okhttp retrofit2

我有一个来自https://developers.google.com/places/web-service/search的简单 Google Places 查询字符串。

以下 URL 显示了对悉尼附近餐馆的搜索。

https://maps.googleapis.com/maps/api/place/textsearch/xml?query=restaurants+in+Sydney&key=YOUR_API_KEY
Run Code Online (Sandbox Code Playgroud)

但是我的 Retrofit2 和 Okhttp3 对其进行编码,如下所示:

https://maps.googleapis.com/maps/api/place/textsearch/xml?query=restaurants%2Bin%2BSydney&key=YOUR_API_KEY
Run Code Online (Sandbox Code Playgroud)

将每个出现的“+”替换为“%2B”。我希望阻止这一切。

请问我该如何实现这个目标?

编辑

我刚刚读完Github问题https://github.com/square/retrofit/issues/1407,没有找到答案

j2e*_*nue 4

这对你有用吗?

Call<List<Articles>> getArticles((@QueryMap(encoded=true) Map<String, String> options); 
Run Code Online (Sandbox Code Playgroud)

编码= true应该告诉retrofit该参数已经被编码。