简体   繁体   English

如何使用Retrofit传递动态JSON文件名

[英]How Do I Pass Dynamic JSON File name using Retrofit

How do I pass Dynamic JSON file name using Retrofit 如何使用Retrofit传递Dynamic JSON文件名

MainActivity.java: MainActivity.java:

final RestAdapter restadapter = new RestAdapter.Builder().setEndpoint("http://www.domain.com/").build();
api flowerapi = restadapter.create(api.class);

api.java: api.java:

public interface api {

    @GET("/JSONS/flowers.json")
   void getData(Callback<List<Flower>> response);

}

As you can see in my above code, I am using only single/one and only flowers.json 正如您在上面的代码中看到的,我只使用单个/一个而且只使用flowers.json

What If I would like to call dynamic json files based on some conditions, like in some cases I have to call flowers.json , in some cases roses.json and in some cases something.json 如果我想根据一些条件来调用动态JSON文件,如在某些情况下,我要叫flowers.json ,在某些情况下roses.json在某些情况下something.json

with the @Path annotation 使用@Path注释

 @GET("/JSONS/{name}")
 void getData(@Path("name") String name, Callback<List<Flower>> response);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何使用动态密钥为 json 创建 POJO 类以进行改造? - how do i create POJO class for json with dynamic keys for retrofit? 如何使用改型在textview中传递包含json数据的变量 - how do i pass varible containing json data in textview using retrofit 如何使用 Retrofit 查询某些 JSON 项目? - How do I query certain JSON items using Retrofit? I want to pass json object as a raw data using @Body in retrofit, but I am unable to add an image file inside the Request Object, how can I achieve it - I want to pass json object as a raw data using @Body in retrofit, but I am unable to add an image file inside the Request Object, how can I achieve it 如何使用Retrofit 2处理动态JSON? - How to handle dynamic JSON with Retrofit 2? 如何使用翻新2正确使用Json Reader在Json中导航? - How do I correctly use Json Reader to navigate in my Json using retrofit 2? 如何使用Gson解析深层嵌套json对象中的字段并在android中进行改造? - How do I parse a field from a deep nested json object using Gson and retrofit in android? 如何使用 Retrofit 将 JSON 主体添加到我的发布请求中? - How do I add a JSON body to my post request using Retrofit? 如何在 Frida 中将动态 class 转换为 json 或 java 文件 - How do I convert dynamic class to json or java file in Frida 在Android中使用翻新时使用带有动态键的JSON - JSON with Dynamic Keys while using Retrofit in Android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM