Closed GoogleCodeExporter closed 9 years ago
See also:
http://stackoverflow.com/questions/6514876/converting-resultset-to-json-faster-o
r-better-way
Original comment by dave.jar...@gmail.com
on 1 Aug 2012 at 12:04
You need to write a custom type adapter.
Original comment by limpbizkit
on 2 Sep 2012 at 9:28
Is this not a common enough feature to warrant implementation?
Original comment by dave.jar...@gmail.com
on 3 Sep 2012 at 12:44
Yes. I too was expecting a default implementation for such kinds of objects.
But there apparently isn't.
Original comment by ashleyli...@gmail.com
on 9 Nov 2012 at 7:49
I was forced by EclipseLink to redefine id field in some of my objects (kind of
bug in EclipseLink...). And now all the json serialization is broken. And there
is no easy way to fix it.
shouldSkipField(FieldAttributes f) cant help because it has no access to the
java type which is actually serializing (you can get a declaring type but it is
an abstract class in my case and the actual class is unknown).
The only way I see now is to exclude this field from a serialization, serialize
object to json tree and add the field manually. Or to write a dozen of adapters.
It would be good to have some mechanism to resolve this issue. Instead of
if (previous != null) {
throw new IllegalArgumentException(declaredType
+ " declares multiple JSON fields named " + previous.name);
}
we can use some policy enum to define behavior. For example "prefer
overridden", "ignore overridden", "throw exception".
Or to add some annotation which can be used on overridden field.
Original comment by kostya31...@gmail.com
on 26 Mar 2014 at 2:40
Original issue reported on code.google.com by
dave.jar...@gmail.com
on 31 Jul 2012 at 11:57