Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SerializedName not working in geocoder CarmenFeature class #695

Closed
cammace opened this issue Jan 10, 2018 · 1 comment
Closed

SerializedName not working in geocoder CarmenFeature class #695

cammace opened this issue Jan 10, 2018 · 1 comment
Assignees
Milestone

Comments

@cammace
Copy link
Contributor

cammace commented Jan 10, 2018

I'm not sure why this is happening but the @SerializedName annotation is supposed to work for both serialization and deserialization but it appears to not work at all. It wasn't noticed until now since we set FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES on the gson object. but if you look at the rawCenter method line, we use @SerializedName("center") but the output when serializing the object is raw_center still. Any ideas on what the issue could be here @zugaldia @tobrun @osana @danesfeder?

@cammace cammace added this to the v3.0.0 milestone Jan 10, 2018
@cammace
Copy link
Contributor Author

cammace commented Jan 17, 2018

This is a result of not using the generated type adapter that the AutoValue Gson uses. Since it's a static method, it can be accessed really easily:

Gson gson = new Gson();
String json = CarmenFeature.typeAdapter(gson).toJson(carmenFeature);
System.out.println(json);

This results in using the annotations as expected but requires a bit more work removing and changing the code I didn't know was getting generated. I predict a few of the TypeAdapterFactorys can be removed. In 0.7 of A-V-G, there's also a @GenerateTypeAdapter annotation which should clean the code up further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant