I'm trying to parse some json with Gson and I have following problem:
This is my json:
[{
"label": "Check Digit",
"value": "W"
},
{
"label": "Equipment",
"value": [
"With Standard Liftgate",
"(-) Version Packages"
]
}]
This is my java class:
public class Decode {
private String label;
private List<String> value = new ArrayList<>();
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public List<String> getValue() {
return value;
}
public void setValue(List<String> value) {
this.value = value;
}
}
How to make Gson to parse it and use value
as Array of String always?
The json is not in proper format, it should be :
Again your parser class should be :
Hope it will help :)
My suggestion is as follows:-
Step 1: Please make following little changes to your
Decode
class.Decode.java
Step 2: Please create following
JsonDeserializer
.MyDeserializer.java
Step 3: Now its time to
deserialize
your json as follows:GsonMain.java