我们的 api 中有以下方法声明:
Call<WeatherResult> getWeatherPredictions(@Query("lat") double latitude, @Query("lon") double longitude);
现在我们使用的 API 相当“简单”,因为它只发回 400
当它对给定的纬度或经度不满意时。他们可以很容易地“修补”他们的值(value)观,但他们不会。
我现在的问题是,有谁知道如何double
s是通过retrofit2转换的吗?我很快查看了源代码,但在那里找不到任何东西。
最佳答案
My question now is, does anybody know how doubles are converted by retrofit2?
他们正在使用 String#valueOf(Object)
。查询是一个接口(interface)。你可以找到它here .文档指出:
Values are converted to strings using {@link String#valueOf(Object)} and then URL encoded.
关于java - 如何使用 retrofit2 将 double 转换为字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38435232/