Giter Site home page Giter Site logo

jsonb-msgpack's Introduction

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).

jsonb-msgpack's People

Contributors

mechite avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.