Closed GoogleCodeExporter closed 9 years ago
Just use a Collection or a List?
Original comment by limpbizkit
on 11 Apr 2012 at 8:36
The problem was that I have big Iterable objects that need to be
serialized. It's not efficient to convert those into Lists or Collections
just for the serialization purpose.
Original comment by phamduc...@gmail.com
on 11 Apr 2012 at 8:52
I have an interface (DAO) with method that returns Iterable<SomeType> and i
want to be able to pass the returned object and it's type to Gson. I cannot be
sure that the object is always a Collection.
Original comment by Ash2kk@gmail.com
on 12 Apr 2012 at 4:31
You should be able to write a TypeAdapterFactory for Iterable. You can use the
type adapter for collection as a guide:
http://code.google.com/p/google-gson/source/browse/trunk/gson/src/main/java/com/
google/gson/internal/bind/CollectionTypeAdapterFactory.java
The code is even simpler if the iterable always has the same type parameter.
Original comment by limpbizkit
on 16 Apr 2012 at 10:36
Why can't or shouldn't it be supported in Gson? Isn't it a valid usecase?
Iterable is Java's built-in type and i expect it to be supported as well as
Collection or Map.
Original comment by Ash2kk@gmail.com
on 17 Apr 2012 at 4:07
Iterable must be supported. It is a very very common & valid usecase.
Original comment by rajkumar...@gmail.com
on 25 Oct 2012 at 7:49
Any suggestions to implementing a TypeAdapterFactory for Iterable? The example
for Collection won't work since TypeAdapterRuntimeTypeWrapper is
package-private.
Also, the Iterable interface does not have an add method so the read method
won't work.
Original comment by jason.di...@gmail.com
on 31 Oct 2012 at 5:06
Hello,
This comment isn't intended to be aggressive or demanding but I'm really
confused by the status of this ticket. Would somebody working on Gson please
provide an explanation as to why this is marked WontFix?
Simply informing users that they can implement this themselves isn't really an
answer - we could all go off and implement our own JSON libraries. Instead I
will have an additional dependency everywhere I use Gson, and will have to
maintain and test this extension. As will countless other users.
Give the increasing functional paradigm being employed in Java and Guava's
judicious use of Iterable (in preference to ? extends Collection) this would
seem like a very obvious use-case.
Also from a performance perspective it just seems crazy to expect me to convert
my Iterable to a Collection just to pass it to Gson to ... iterate over it
again. And rewriting my code to suit Gson is obviously absurd and out of the
question.
If anything throw out the Collection TypeAdapterFactory etc and replace with a
single Ierable version. I strongly suspect this ticket will receive votes from
every Gson user when Java 8 is released.
Please comment with the rationale behind closing this.
I would also like to thank you for providing a nice, tidy library - so thanks =)
Original comment by ear...@gmail.com
on 8 Nov 2012 at 5:48
Please reopen this issue.
Original comment by eirir...@gmail.com
on 9 Oct 2013 at 9:53
Please resolve this issue.Having the same problem. Any alternate for this?
Original comment by vivek.sr...@gmail.com
on 16 Oct 2013 at 5:49
From the front page:
Gson Goals:
* Extensive support of Java Generics
* Support arbitrarily complex objects (with deep inheritance hierarchies and
extensive use of generic types)
Yet for some reason refuse to support such a fundamental, basic type such as
Iterable.
Original comment by collinsa...@gmail.com
on 23 Jan 2015 at 5:25
Original issue reported on code.google.com by
Ash2kk@gmail.com
on 1 Apr 2012 at 7:38Attachments: