Kotlin 使用JSON参数修改GET请求
我正试图通过改造我的自定义对象从解析服务器获取数据 http请求将是:Kotlin 使用JSON参数修改GET请求,kotlin,retrofit2,Kotlin,Retrofit2,我正试图通过改造我的自定义对象从解析服务器获取数据 http请求将是: https://MY.SERVER./1/classes/Fiestas?where={"Epoca":{"__type":"Pointer","className":"Epocas","objectId":"myObjectId"}} 所以我有这个界面: @GET("Fiestas?where={\"Epoca\":{\"__type\":\"Pointer\",\"className\":\"Epocas\",\"ob
https://MY.SERVER./1/classes/Fiestas?where={"Epoca":{"__type":"Pointer","className":"Epocas","objectId":"myObjectId"}}
所以我有这个界面:
@GET("Fiestas?where={\"Epoca\":{\"__type\":\"Pointer\",\"className\":\"Epocas\",\"objectId\":\"{epoca_id}\"}}")
fun getFiestaByEpocaId(@Path("epoca_id") epoca_id: String): Deferred<JSONResponse>
有人知道在kotlin中发送JSON内部GET改造请求的解决方案吗
谢谢 您可以尝试以下方法:
@GET("Fiestas")
fun getFiestaByEpocaId(
@Query("where") jsonString: String
): Call<JSONObject>
并在请求方法之前调用jsonString.replace(“\”,“”)
@GET("Fiestas")
fun getFiestaByEpocaId(
@Query("where") jsonString: String
): Call<JSONObject>
val jsonString = "{\"__type\":\"Pointer\",\"className\":\"Epocas\",\"objectId\":\"{epoca_id}\"}}"