# \[ANN\] data-encoding.0.5 release

**URL:** <https://discuss.ocaml.org/t/ann-data-encoding-0-5-release/9420>\
**Category:** Community\
**Tags:** announce\
**Created:** [February 26, 2022, 10:36am UTC](https://discuss.ocaml.org/t/ann-data-encoding-0-5-release/9420 "2022-02-26T10:36:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![raphael-proust](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/raphael-proust/32/415_2.png) [@raphael-proust](https://discuss.ocaml.org/u/raphael-proust)\
**Post date:** [February 26, 2022, 10:36am UTC](https://discuss.ocaml.org/t/ann-data-encoding-0-5-release/9420/1 "2022-02-26T10:36:18Z")

</div>

On behalf of [Nomadic Labs](https://www.nomadic-labs.com/), I’m happy to announce the release of data-encoding version 0.5.

This new version brings several bug fixes, some increased test coverage, minor improvements in the API, and a major new feature:

## Compact encodings: sub-byte tag sizes

This new version provides a new set of combinators for _compact_ encodings. These compact encodings will handle all the verbose and error-prone bit-twidling process needed to combine multiple sub-byte discriminators into a single byte-size one.

E.g., the encoding `let e1 = either (either bool unit) (option bool)` uses three bits in the shared tag and zero bytes after that;  
the encoding `let e2 = either int32 int64` uses one bit in the shared tag and either 4 or 8 bytes to represent the integer;  
the product encoding `let ee = tup2 e1 e2` uses four (3 + 1) bits in the shared tag and either 4 or 8 bytes to represent the integer of `e2`.

## How to get

The code is available under MIT license on [Nomadic Labs / data-encoding · GitLab](https://gitlab.com/nomadic-labs/data-encoding).

It can be installed via `opam`.

---

<div class="post-metadata">

**Author:** ![dario](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@dario](https://discuss.ocaml.org/u/dario)\
**Post date:** [February 28, 2022, 9:32pm UTC](https://discuss.ocaml.org/t/ann-data-encoding-0-5-release/9420/2 "2022-02-28T21:32:29Z")

</div>

Hi @raphael-proust! I have a question regarding the connection between `data-encoding` and `json-data-encoding`, also developed at Nomadic Labs. The latter seems tied to JSON, whereas the former is more flexible, supporting also binary encodings. However, since `data-encoding` also supports JSON, doesn’t it subsume `json-data-encoding` completely?

---

<div class="post-metadata">

**Author:** ![raphael-proust](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/raphael-proust/32/415_2.png) [@raphael-proust](https://discuss.ocaml.org/u/raphael-proust)\
**Post date:** [March 1, 2022, 7:25am UTC](https://discuss.ocaml.org/t/ann-data-encoding-0-5-release/9420/3 "2022-03-01T07:25:32Z")

</div>

Hello @dario ,

The `data-encoding` library uses `json-data-encoding` for its JSON backend. It delegates conversion from OCaml values into and from JSON to the primitives provided in the interface of `json-data-encoding`.

In a way, yes, as an end-user you don’t need to use `json-data-encoding` directly because you can use the `Json` module of `data-encoding` instead. There are three possible reasons why you might add `json-data-encoding` as a (non-transitive) dependency to your project and use it directly in your code:

- You want to keep the dependency set and the number of abstraction layers as small as possible. E.g., in order to reduce binary size.

- You want some static guarantees that some encodings are only every used for JSON. E.g., in your logging system.

- You need to define a JSON encoding which is rejected by `data-encoding` on grounds that it is invalid in binary. Note that

---

<div class="post-metadata">

**Author:** ![raphael-proust](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/raphael-proust/32/415_2.png) [@raphael-proust](https://discuss.ocaml.org/u/raphael-proust)\
**Post date:** [March 1, 2022, 7:26am UTC](https://discuss.ocaml.org/t/ann-data-encoding-0-5-release/9420/4 "2022-03-01T07:26:03Z")

</div>

Version 0.5.1 of the data-encoding has just been released.

This is a bugfix release making one of the library’s internal checks more permissive. Without this fix (i.e., using version 0.5), some valid encodings are rejected (raising `Invalid_argument`) by the library.

You can update via opam: `opam install data-encoding.0.5.1`
