This is related to the previous question I asked here earlier
Parsing JSON using Gson
I am trying to parse the same JSON, but now I have slightly modified my classes.
{ "lower": 20, "upper": 40, "delimiter": " ", "scope": ["${title}"] }
Now my class is as follows:
public class TruncateElement { private int lower; private int upper; private String delimiter; private List<AttributeScope> scope;
This code throws an exception,
com.google.gson.JsonParseException: The JsonDeserializer EnumTypeAdapter failed to deserialized json object "${title}" given the type class com.amazon.seo.attribute.template.parse.data.AttributeScope at
The exception is clear because, according to the solution to my previous question, GSON expects Enum objects to actually be created as
${title}("${title}"), ${description}("${description}");
But since this is syntactically impossible, what are the recommended solutions, workarounds?
java json gson
Sachin Kulkarni Nov 21 2018-11-11T00: 00Z
source share