android – 在json对象里面改造后发布数组?

我正在进行改造并通过post方法向服务器发送请求我现在得到这个json的响应,看到这是我发送到服务器的帖子.

adreess class for post i m using this object

 {
 "years":"1855",
 "months":"6",
 "skills":1
}

now i have to implement array inside object in skills how to post this

  {
  "years":"1",
 "months":"6",
"skills":["1","2","3"],
    }

如何在改造中获取对象内部的数组
我使用这样的界面

        Call<AddressResponce> address(@Body Adreess adreess);

解决方法:

package com.example;

import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

public class Example {

@SerializedName("years")
@Expose
private String years;
@SerializedName("months")
@Expose
private String months;
@SerializedName("skills")
@Expose
private List<String> skills = null;

public String getYears() {
return years;
}

public void setYears(String years) {
this.years = years;
}

public String getMonths() {
return months;
}

public void setMonths(String months) {
this.months = months;
}

public List<String> getSkills() {
return skills;
}

public void setSkills(List<String> skills) {
this.skills = skills;
}

}

我希望它对你有用..!

上一篇:五、搭建Redis 集群


下一篇:源码笔记之Retrofit