I have a class with some fields:
public class GsonRepro {
class A {
private List<String> field1 = new ArrayList<>();
private String name;
private Integer status;
public A(){
}
public List<String> getfield1() { return field1; }
public void setField1(List<String> field1) { this.field1 = field1; }
public String getName() { return name; }
public void setName() { this.name = name; }
public Integer getStatus() { return status; }
public void setStatus(int status) { this.status = status; }
}
public static void main(String[] args) {
String str = "{\"name\":\"my-name-1\",\"status\":0,\"field1\":[\"0eac6b1d3d494c2d8568cd82d9d13d5f\"]}";
A a = new Gson().fromJson(str, A.class);
}
}
All fields are parsed but the List<String> field1
, how can I get this to work?
Solution:
The code above works just fine. Initially, I just had a typo in the List field.