Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/valaphee/jackson-dataformat-nbt
Support for reading and writing NBT-encoded data via Jackson abstractions.
https://github.com/valaphee/jackson-dataformat-nbt
jackson jackson-databind nbt nbt-data nbt-format nbt-parser
Last synced: about 1 month ago
JSON representation
Support for reading and writing NBT-encoded data via Jackson abstractions.
- Host: GitHub
- URL: https://github.com/valaphee/jackson-dataformat-nbt
- Owner: valaphee
- License: apache-2.0
- Created: 2022-01-15T00:24:58.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-13T21:40:15.000Z (about 2 years ago)
- Last Synced: 2023-07-26T22:54:59.443Z (over 1 year ago)
- Topics: jackson, jackson-databind, nbt, nbt-data, nbt-format, nbt-parser
- Language: Kotlin
- Homepage:
- Size: 188 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
## Overview
[Jackson](../../FasterXML/jackson) (Java) data format module that supports reading and writing
[NBT](NBT.txt) ("Named Binary Tag") encoded data.
Module extends standard Jackson streaming API (`JsonFactory`, `JsonParser`, `JsonGenerator`),
and as such works seamlessly with all the higher level data abstractions (data binding, tree model, and pluggable extensions).# Dependency
To use this extension on Maven-based projects, use following dependency:
```xml
com.valaphee
jackson-dataformat-nbt
1.1.8```
and for Gradle-based projects:
```kotlin
implementation("com.valaphee:jackson-dataformat-nbt:1.1.8")
```## Usage
Basic usage is by using `NbtFactory` in places where you would usually use `JsonFactory`
```java
ObjectMapper mapper = new ObjectMapper(new NbtFactory())
.registerModule(new SimpleModule().addAbstractTypeMapping(Map.class, DeepEqualsLinkedHashMap.class))
.addHandler(EmbeddedObjectDeserializationProblemHandler.INSTANCE);
// and then read/write data as usual
SomeType value = ...;
byte[] nbtData = mapper.writeValueAsBytes(value);
SomeType otherValue = mapper.readValue(nbtData, SomeType.class);
```Implementation allows use of any of 3 main operating modes:
* Streaming API (`NbtParser` and `NbtGenerator`)
* Databinding (via `ObjectMapper` / `ObjectReader` / `ObjectWriter`)
* Tree Model (using `TreeNode`, or its concrete subtype, `JsonNode` -- not JSON-specific despite the name)and all the usual data-binding use cases exactly like when using `JSON` or `Smile` (2 canonical 100% supported Jackson data formats).