Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kotlin 使用JSON参数修改GET请求_Kotlin_Retrofit2 - Fatal编程技术网

Kotlin 使用JSON参数修改GET请求

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

我正试图通过改造我的自定义对象从解析服务器获取数据

http请求将是:

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}\"}}"