Support
Quality
Security
License
Reuse
kandi has reviewed eclipse-collections and discovered the below as its top functions. This is intended to give you an instant insight into eclipse-collections implemented functionality, and help decide if they suit your requirements.
Get all kandi verified functions for this library.
Get all kandi verified functions for this library.
Eclipse Collections is a collections framework for Java with optimized data structures and a rich, functional and fluent API.
QUESTION
How to deserialise Eclipse Collections types?
Asked 2021-Jun-25 at 03:24I came across this library eclipse-collections and it fits my use case. But unfortunately, I am not able to deserialize it using either Gson or Jackson - the two most popular libraries for serialization/deserialization.
Does any of the two libraries provide support for eclipse collections? If yes, then how?
ANSWER
Answered 2021-Jun-25 at 03:24One of the docs on the Readme of the official github repo of eclipse-collections mentions:
Unfortunately, with new collection types comes incompatibility with normal serialization frameworks. Jackson, arguably the most popular JSON serialization framework for Java, is unable to deserialize Eclipse Collections types out-of-the-box. For this purpose, there is now a Jackson module supporting most Eclipse Collections types directly (including primitive collections).
Not only do they mention the issue but they also provide the solution to it. All you need to do is register the EclipseCollectionsModule
with Jackson's ObjectMapper
object like so:
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.eclipsecollections.EclipseCollectionsModule;
ObjectMapper mapper = new ObjectMapper().registerModule(new EclipseCollectionsModule());
Once you have done the above, you can now use the ObjectMapper as usual. So,
MutableIntLongMap myDeserialisedVariable = mapper.readValue(jsonString, MutableIntLongMap.class);
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
See Similar Libraries in
Save this library and start creating your kit
Open Weaver – Develop Applications Faster with Open Source