Closed GoogleCodeExporter closed 9 years ago
Here's a modified JsonReader that dumbly handles this particular case by
creating a new ArrayList when it detects a constructor arg of type List, along
with accompanying test TestJsonReaderWriter.testException. Several other common
java types could be handled like this, although it's sort of plugging holes in
the dike.
Original comment by EricKu...@gmail.com
on 23 Sep 2013 at 9:10
Attachments:
I will review and likely add / update with your changes. I understand what you
mean by "like plugging holes in the dike." Java needs a C-style malloc() for
objects, at least when you are performing serialization. I will likely add
some other "popular" classes (Collections, Map, String, Date, etc.) the usual
suspects that end up as 'fields' on data transfer (model) classes. Good find
and thanks for providing a solution / test.
Original comment by jdereg@gmail.com
on 24 Sep 2013 at 3:07
Hi
I also have this issue on a simple pojo with JDK7
I have a simple bean with string name, int amount, int total and boolean
accepted with a default empty constructor and getter and setter for each
property.
I can serialise this type to a JSON String fine but when I try to deserialise I
get the exact same exception as Erick.
I am trying to use the library in a REST service so when deserialising there
can be an array of types needed by the java REST service and this library
seemed just what I was looking for.
Any resolution to this would be greatly appreciated.
Regards
Steve
Original comment by steven.m...@gmail.com
on 26 Sep 2013 at 10:52
This issue has been addressed. The code now tries the default constructor
(public, private, protected, or package friendly). If that does not work (or
there is no constructor that takes no arguments, or the no-arg constructor
throws an exception), then it tries construction with defaults for primitivies
and null for non-primities, for all constructors. If that does not work, it
tries defaults for primitives, and non-null values for a wide range of common
classes (Collection, String, Date, Timezone, etc). A new test case has been
added for this.
Original comment by jdereg@gmail.com
on 27 Sep 2013 at 11:00
Original issue reported on code.google.com by
EricKu...@gmail.com
on 23 Sep 2013 at 5:49