Skip to main content

Embedded Binary JSON

Project description

Embedded Binary JSON

What is EBJ?

EBJ is a format that focuses on storing binary json use RIGHT size.

Byte Order

EBJ always use little-endian. It is more friendly for morden CPU to parse.

Type Codes

0x00 int8
0x01 int16
0x02 int32
0x03 int64
0x04 float32
0x05 float64
0x06 str8 (uint8 length)
0x07 str32 (uint32 length)
0x08 ref8 (str only)
0x09 ref32 (str only)
0x0A true
0x0B false
0x0C null
0x0D array
0x0E end (array, object)
0x0F object
0x10 0
0x11 1
0x12 2
...
0xFF 239

EBJ strXX should be encoded as UTF-8 bytes.

How to use EBJ?

This repo contains a base Python version EBJ implementation called ebj2. The following lines show how to use ebj2 to dump and load EBJ bytes.

Install:

pip install ebj2

Usage:

# Load module
import ebj2

# Dump EBJ
byts = ebj2.dumps(['ebj2 is awesome!'])

# Load EBJ
msgs = ebj2.loads(byts)

# Dump to fp
ebj2.dump([], fp)

# Load from fp
ebj2.load(fp)

Why should i use EBJ?

At least EBJ will save your 33% disk space to store json. Also it is very fast. (ebj2 maybe very slow, because it use pure-python, but still usable)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

ebj2-0.0.1-py3-none-any.whl (3.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page