Comments (4)
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 [email protected]
on 23 Sep 2013 at 9:10
Attachments:
from json-io.
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 [email protected]
on 24 Sep 2013 at 3:07
- Changed state: Accepted
from json-io.
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 [email protected]
on 26 Sep 2013 at 10:52
from json-io.
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 [email protected]
on 27 Sep 2013 at 11:00
- Changed state: Done
from json-io.
Related Issues (20)
- assumes private fields are unique in class hierarchy HOT 7
- Abbreviation for package path HOT 1
- Import library? HOT 3
- Serializing Maps as Simple JSON Maps HOT 2
- serializing an empty ArrayList produces {} instead of [] HOT 4
- java.io.IOException: Class instance 'Foo' could not be created at position 10533 HOT 3
- Access to JsonObject.target required in custom JsonClassReaders HOT 1
- Serializing breaks for java.util.Date subclasses HOT 2
- cloneObject(String s) HOT 1
- JsonWriter not working as expected for single string input; works for other types HOT 1
- IllegalAccessException HOT 1
- maybe unnecessary call of convertParsedMapsToJava inside JsonReader.readObject()
- Feature request: add a optional fallback type parameter for the toplevel json container to JsonReader.jsonToJava(json); HOT 1
- loadClass(name) raises ClassNotFound Exception although Class exists / solution available
- json for enum includes private fields, causes error when parsing
- JsonWriter.objectToJson breaks on HashMap<Double, Double>
- Feature request: Totally disable '@type' field
- Double.NaN not handled correctly. HOT 1
- Float NaN value causes token exception (expects null)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json-io.