https://github.com/lundegaard/lundegaard-commons-java-jackson
Library for simple startup with object de/serialization to/from JSON using Jackson.
https://github.com/lundegaard/lundegaard-commons-java-jackson
commons jackson java json
Last synced: 2 months ago
JSON representation
Library for simple startup with object de/serialization to/from JSON using Jackson.
- Host: GitHub
- URL: https://github.com/lundegaard/lundegaard-commons-java-jackson
- Owner: lundegaard
- License: other
- Created: 2019-07-26T10:02:43.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-11-16T02:55:56.000Z (over 3 years ago)
- Last Synced: 2025-07-19T13:31:57.762Z (12 months ago)
- Topics: commons, jackson, java, json
- Language: Java
- Size: 45.9 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[](https://search.maven.org/search?q=g:eu.lundegaard.commons.java%20AND%20a:jackson) [](https://www.javadoc.io/doc/eu.lundegaard.commons.java/jackson)
# Lundegaard Java Commons - Jackson
This library is used for simple startup with object de/serialization to/from JSON using Jackson.
## Usage
Just add it as dependency, e.g. into Maven (use the latest version)
```xml
eu.lundegaard.commons.java
jackson
${lundegaard.commons.jackson.version}
```
### De/serialization
You can use simple pre-configured object mapper via `SerializingUtil`. For serialization into JSON:
```java
MyObject myObject = new MyObject(...);
String json = SerializingUtil.serializeToJson(object);
```
For deserialization from JSON
```java
String json = ...
MyObject myObject = SerializingUtil.deserializeFromJson(json, MyObject.class);
```
### Custom ObjectMapper
If you need to customize the `ObjectMapper`, then obtain one using
```java
ObjectMapper mapper = ObjectMapperFactory.createObjectMapper()
```
This mapper is standard pre-configured Jackson `ObjectMapper` and can be further customized.
The mapper is thread-safe and thus should be shared and reused. **Best practice is storing it in singleton instance or similar**.
## Pre-configured object mapper
We use pre-configured Jackson `ObjectMapper`. This means that the mapper has registered Java 8 types (`Optional`, `java.time.*`, etc.) and is configured to match our most common needs (interoperability with our JS frontends, readable timestamps). For specific configuration, please refer to the `eu.lundegaard.commons.jackson.ObjectMapperFactory`.