Comments (2)
Recently, support for USE_MAPS was added to JsonReader.jsonToJava(). When USE_MAPS = true, the return value is a generic JsonObjects (Maps) where objects would be. The root of the JSON is the same as the original type of root object (e.g., string, double, long, null, etc. or Map if the root was an Object).
With this change, JsonReader.jsonToMaps() is no longer needed and will be deprecated. All jsonToMaps does now, is to ensure that the return value is always a Map. When this change was made, it did eliminate the need for the JsonObject.getArray() and JsonObject.isArray() methods in almost all cases. At this point, the only time you would use .getArray() or .isArray() would be if the root element of your object graph was an Collection type (ArrayList for example). In that case, in order to ensure that the right type is returned, the root element will have @type='arrayList' with "@Items":[item 1, item 2, ...].
In the example above, if you had called JsonReader.jsonToJava(json), then the ArrayList would be returned and no big deal. But, if you had called JsonReader.jsonToJava(json, [(JsonReader.USE_MAPS):true]), then a JsonObject would be returned that represents the root ArrayList object. You would call .getArray() to fetch it's items.
For brevity, I am using Groovy syntax for a Map of args above.
from json-io.
Thanks for the help. I understand how it works now. :)
from json-io.
Related Issues (20)
- Possible issue about list of objects that have custom writers HOT 5
- Java class version 55 for 4.14.2 HOT 3
- Revisiting issue 17 HOT 6
- Enums are serialized differently with 4.15.0 HOT 3
- 4.15 --> 4.16 default mapping method fails to parse HOT 7
- Enhance the robustness of tests
- ReadOptionsBuilder HOT 1
- Compile / runtime dependency on com.novell.ldap:jldap HOT 3
- How to deserialise javafx classes with inaccessible fields? HOT 2
- Request for tutorial HOT 2
- NoSuchMethodError after upgrade HOT 24
- Custom serialising of objects with inheritance HOT 2
- Encoding Bug for JsonIo.toJson("🙊🙉🙈", null)? HOT 3
- Custom Writers not including id and ref in output? HOT 3
- Compatibility between 4.14.0 and 4.20.0 HOT 4
- User guide Untyped Usage HOT 1
- high usage of metaspace after upgrade to 4.22.0 HOT 4
- memory leak on LRUCache HOT 12
- Could not find class: java.time.ZoneRules which has associated alias value: ZoneRules config/aliases.txt HOT 2
- Stack usage HOT 2
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.