https://github.com/ops4j/org.ops4j.mpjp
MessagePack JSON Provider
https://github.com/ops4j/org.ops4j.mpjp
Last synced: 9 months ago
JSON representation
MessagePack JSON Provider
- Host: GitHub
- URL: https://github.com/ops4j/org.ops4j.mpjp
- Owner: ops4j
- License: apache-2.0
- Created: 2018-12-02T20:16:12.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-02T20:50:52.000Z (over 7 years ago)
- Last Synced: 2025-07-23T21:25:43.046Z (12 months ago)
- Language: Java
- Size: 32.2 KB
- Stars: 0
- Watchers: 69
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MessagePack JSON Provider
## Purpose
This library is an alternative [JsonProvider](https://javaee.github.io/javaee-spec/javadocs/javax/json/spi/JsonProvider.html)
for JSON-P and JSON-B which lets you serialize Java objects to binary streams in [MessagePack](https://msgpack.org/) format,
and vice versa.
## Basic Usage
````java
// Create Jsonb instance with custom JSON-P provider
Jsonb jsonb = JsonbBuilder.newBuilder().withProvider(new MessagePackJsonProvider()).build();
// Java to MessagePack
Person person = new Person("Mickey", "Mouse");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
jsonb.toJson(person, baos);
// MessagePack to Java
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
Person deserialized = jsonb.fromJson(bais, Person.class);
````
## Motivation
The existing [msgpack-java](https://github.com/msgpack/msgpack-java) project contains a Java data binding library based on Jackson.
Working in a Java EE 8 environment, it would be a burden to use another Java-to-Json-binding solution (i.e. Jackson) on top of the
one provided by the platform (i.e. JSON-B).
This library avoids the Jackson dependency by using `msgpack-core` together with a custom JSON-P provider which serializes to
and from MessagePack instead of JSON.
The more complex part of Java data binding is completely left to JSON-B.
At the moment, this library is only tested with the Yasson reference implementation.