-
Notifications
You must be signed in to change notification settings - Fork 34
Add support for top-level json lists #143
Comments
Finally getting around to looking closely at this. In order to maintain parity with Gson, if a class implements the list interface or is an array, we will use the logic from Gson which serializes all lists and arrays the same way: if (type instanceof GenericArrayType || type instanceof Class && ((Class<?>) type).isArray()) {
// return array adapter
} then it will be serialized as a For example, given the following class: @UseStag
class Test extends ArrayList<String> {
@SerializedName("test_field")
public String testField;
} With this initialization: final Test test = new Test();
test.add("one");
test.add("two");
test.add("three");
test.testField = "four"; The class will be serialized to:
and as there is no way to represent a list with extra fields, only lists declared like above will be able to be parsed into objects that extend the The easiest implementation would be to change |
Issue Summary
A server response such as
maps to a model like:
stag fails generating code these top-level array objects.
Reproduction Steps
See above
Expected Behavior
Extending ArrayList should produce valid code
Actual Behavior
Fails to generate.
The text was updated successfully, but these errors were encountered: