问题
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","taskData":{"userID":"1"}}
回答1:
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)
- From GsonFormattor plugin
This plug-in convert your Json to Model class
- 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.
来源:https://stackoverflow.com/questions/42949839/android-retrofit-post-whole-pojo-using-this-format