mechite / jsonb-msgpack Goto Github PK
View Code? Open in Web Editor NEWJsonb adapter that adds support for the MessagePack binary format.
License: Apache License 2.0
Jsonb adapter that adds support for the MessagePack binary format.
License: Apache License 2.0
jsonb-msgpack ============= This is a simple adapter that adds support for the MessagePack binary format available at https://msgpack.org/ to Avaje Jsonb. If you include this JAR into your project (and with JPMS, the module-path), there are no further steps needed to be taken if you would like to use the default adapter settings; this adapter is located automagically with Java's ServiceLoader by Avaje Jsonb. Currently, the `msgpack-java` module is added as a Git submodule, meaning that you do not need to separately add that dependency to your project as it is a part of this source tree, however this does mean that you should even avoid\ also including that JAR as it could cause a clash unless you are using JPMS. module-info.java =============== requires io.avaje.jsonb.msgpack; ================================ Public API ========== The public API consists of the following classes (package io.avaje.jsonb.msgpack): * MsgpackAdapter * MsgpackAdapterFactory These can be used to obtain readers and writers. MsgpackWriter uses a lazy-evaluation style of writing in order to support the model expected with JSON (where we can keep writing elements to an array or object before closing it), as MessagePack requires the size of a map or array to be known before adding elements as it appends only a header. Here is a mock of how MessagePack would handle a simple JSON structure: JSON: { "name": "John Doe", "age": 20, "locations": [ { "id": 246813579024680246, "address": "28/32 High St N, London E6 2HJ" }, { "id": 271828182827182818, "address": "Tollgate Rd, London E6 5JP" }, ] } Pseudo-MessagePack (where semicolon is used as a separator): MAP OF 3 ELEMENTS; "name"; "John Doe"; "age"; 20; "locations"; ARRAY OF 2 ELEMENTS; MAP OF 2 ELEMENTS; "id"; 246813579024680246; "address"; "28/32 High St N, London E6 2HJ"; MAP OF 2 ELEMENTS; "id"; 271828182827182818; "address"; "Tollgate Rd, London E6 5JP"; As you can see here, there is no concept of a terminator. When a certain element will end is dictated right at the beginning with a length field. This is also how raw binary data is able to be written, as you can simply write a byte[] and have it be translated to a header, e.g., "BINARY with 928341902490120 bytes", and already know when to expect the stream to end. While the lazy evaluation technique works in this case, it leads to a single writer not being reusable to write multiple root nodes (which is acceptable in most cases, however if one were to use JsonWriter directly for, e.g., logging, where it might make sense to keep reusing a writer, it would be detrimental).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.