android retrofit ,post whole Pojo using this format

后端 未结 1 1506
耶瑟儿~
耶瑟儿~ 2021-01-27 08:09

I want to post this kind of request in retrofit2 so if someone have idea about it then it would be great help of mine.

reqObject={\"task\":\"singleUser\",\"taskD         


        
相关标签:
1条回答
  • 2021-01-27 08:34

    Yes, good Question It is some what not understandable for Beginner.

    So I combining some Answers for you.

    first step

    make your Json -> model class (or POJO class)

    1. From GsonFormattor plugin

    This plug-in convert your Json to Model class

    1. Pojo genrator

    Go to this link , copy and paste Your Json and simply make your model class.

    OK , we completed our first step

    Second Step

    Set all value to your Model class what You want from getter() setter().

    Retrofit having @Body annotation that use in your case

    @POST("/jayson")
    FooResponse postJson(@Body MyGsonModelClass body);
    

    Where MyGsonModelClass is class we made from first step.

    0 讨论(0)
提交回复
热议问题