Git Product home page Git Product logo

ebj2's Introduction

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

ebj2's People

Contributors

urain39 avatar

Watchers

 avatar  avatar

ebj2's Issues

0.0.2 Updates

  1. Fix cannot decode zero-length bytes
  2. Use wrapped exception instead struct.error
  3. Add docstring

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.