Permalink
Fetching contributors…
Cannot retrieve contributors at this time
172 lines (128 sloc) 3.26 KB

AsciiPack

AsciiPack is an object serialization inspired by MessagePack.

AsciiPack is use easy by Web. because all serialize object is only writed by ascii strings.

JSON is 27 chars:
{"compact":true,"binary":0}

AsciiPack is 19 chars:
r2NcompactYMbinary0
    r2 => map of length 2.
    Ncompact => string of length 7 and value is "compact".
    Y => true.
    Mbinary => string of length 6 abd value is "binary".
    0 => fixint value is 0.

Formats

Overview

format namefirst char
int 4a
int 8b
int 16c
int 32d
int 64e
(blank)f
uint 8g
uint 16h
uint 32i
uint 64j
float 32k
float 64l
(blank)m
str 8n
str 16o
str 32p
(blank)q
map 4r
map 8s
map 16t
map 32u
array 4v
array 8w
array 16x
array 32y
(blank)z
positive fixint0-9A-F
fixstrG-V
nilW
falseX
trueY
(blank)Z

Notation in diagrams

All object serialize format.
key | [length] | [variable]

`F` is Hexadecimal number by one char.
`D` is Decimal number.

int

int 4:
a | F

int 8:
b | FF

int 16:
c | FFFF

int 32:
d | FFFFFFFF

int 64:
e | FFFFFFFFFFFFFFFF

positive fixint:
0-9A-F

uint 8:
g | FF

uint 16:
h | FFFF

uint 32:
i | FFFFFFFF

uint 64:
j | FFFFFFFFFFFFFFFF

float

Value abide IEEE 754 format.

float 32:
k | FFFFFFFF

float 64:
l | FFFFFFFFFFFFFFFF

str

fixstr:
G-V | data

str 8:
n | FF | data

str 16:
o | FFFF | data

str 32:
p | FFFFFFFF | data

map

map 4:
r | F | N * (key + value)

map 8:
s | FF | N * (key + value)

map 16:
t | FFFF | N * (key + value)

map 32:
u | FFFFFFFF | N * (key + value)

* N is the size of map

array

array 4:
v | F | N * value

array 8:
w | FF | N * value

array 16:
x | FFFF | N * value

array 32:
y | FFFFFFFF | N * value

* N is the size of array

nil

nil:
W

boolean

false:
X

true:
Y

Comparison

Serializer Length Speed Readability Writability
JSON ×
MessagePack × ×
AsciiPack

Demo

Interactive demo site http://ksss.github.io/AsciiPack/ (using /js/asciipack.js)