Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jviotti/jsonbinpack-poc
This is a PoC. See https://github.com/sourcemeta/jsonbinpack for the production implementation.
https://github.com/jviotti/jsonbinpack-poc
binary deserialization json json-schema jsonschema serialization space-efficiency
Last synced: 3 months ago
JSON representation
This is a PoC. See https://github.com/sourcemeta/jsonbinpack for the production implementation.
- Host: GitHub
- URL: https://github.com/jviotti/jsonbinpack-poc
- Owner: jviotti
- License: apache-2.0
- Archived: true
- Created: 2021-02-19T15:08:34.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-07-22T01:58:21.000Z (over 2 years ago)
- Last Synced: 2024-09-21T08:02:51.435Z (3 months ago)
- Topics: binary, deserialization, json, json-schema, jsonschema, serialization, space-efficiency
- Language: TypeScript
- Homepage: https://www.jsonbinpack.org
- Size: 36.5 MB
- Stars: 22
- Watchers: 4
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
[![GitHub Actions](https://github.com/jviotti/jsonbinpack/actions/workflows/nodejs.yml/badge.svg?branch=main)](https://github.com/jviotti/jsonbinpack/actions/workflows/nodejs.yml)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com)JSON BinPack
============JSON BinPack is an open-source binary [JSON](https://www.json.org)
serialization format with a strong focus on space efficiency. It can run in
schema-driven and schema-less mode to encode any JSON document given a matching
[JSON Schema 2020-12](http://json-schema.org) definition.***
**NOTE! This is a prototype pre-production JavaScript-based implementation to prove the
feasability of the approach. See https://github.com/sourcemeta/jsonbinpack for the work-in-progress C++
implementation.*****
Documentation
-------------### Installation
```sh
npm install --save jsonbinpack
```### Example
```javascript
const jsonbinpack = require('jsonbinpack')// Declare a JSON Schema definition
const schema = {
$schema: 'https://json-schema.org/draft/2020-12/schema',
type: 'object',
properties: {
foo: { type: 'string' }
}
}// (1) Compile the JSON Schema definition into an Encoding schema
const encodingSchema = await jsonbinpack.compileSchema(schema)// (2) Serialize a matching JSON document using the Encoding schema
const buffer = jsonbinpack.serialize(encodingSchema, {
foo: 'bar'
})// (3) Deserialize the buffer into the original JSON document
const result = jsonbinpack.deserialize(encodingSchema, buffer)console.log(result)
> { foo: 'bar' }
```### Reference
#### `jsonbinpack.compileSchema(JSON Schema): Promise`
Convert a JSON Schema definition into an Encoding schema for use with the
`.serialize()` and `.deserialize()` functions.#### `jsonbinpack.serialize(Encoding, JSON): Buffer`
Serialize a JSON value according to an Encoding schema.
#### `jsonbinpack.deserialize(Encoding, Buffer): JSON`
Deserialize a buffer according to an Encoding schema.
Building from source
--------------------Requirements:
- Node.js
- `npm`
- GNU MakeInstalling dependencies:
```sh
npm install
```Compiling the project:
```sh
make
# Run tests
make test
# Run linter
make lint
```License
-------This project is released under the terms specified in the
[license](https://github.com/jviotti/jsonbinpack/blob/main/LICENSE).