How to create a correct pojo class for the below json and display the "mcategory_id" and "effect_list" in textview using Retrofit 2
{
"categories":[
{
"mcategory_id":"14"
}
],
"effect_list":{
"14":[
{
"effects_id":"164"
}
]
}
}
使用此链接创建您的Java文件JsonToJavaConversion
You will have a class Category with attribute mcategory_id. Then you will have a class effect_list which will contain a list of items that contains "effects_id". So basically you will need 4 classes.
Class Category with mcategory_id.
Class Effects with effects_id.
Class Effect_list (in your json is a object not a list) which will contain a list of Effects ("14" name in your json)
And a response class for your retrofit: Retrofit class will contain List of Category("categories"called in your json) and a object of Effect_list(called "effect_list" in your json).
Use annotation @SerializedName so that you can map easily the json into your objects.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.