android改造,使用此格式发布整个Pojo [英] android retrofit ,post whole Pojo using this format
问题描述
我想在Retrofit2中发布这种请求,因此,如果有人对此有想法,那将对我有很大帮助.
reqObject = {"task":"singleUser","taskData":{"userID":"1"}}
是的,很好的问题对于 初学者
,这是一些无法理解的.
所以我为您合并了一些答案.
第一步
创建您的Json->模型类(或POJO类)
转到此链接,复制并粘贴您的Json并简单地创建模型类.
好的,我们完成了第一步
第二步
将您想要的所有值从
getter()setter()
设置为您的Model类.在您的情况下使用的具有
@Body
批注的改装@POST("/jayson")FooResponse postJson(@Body MyGsonModelClass body);
MyGsonModelClass
是我们从 第一步 制作的类.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"}}
解决方案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)
This plug-in convert your Json to Model class
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.这篇关于android改造,使用此格式发布整个Pojo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!