Skip to content

Chummy Object Notation is a data interchange format and a serialization format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other serializable values). Or it can use the most suitable serialization format to serialize data objects consisting of attribute–value pairs and array…

License

Notifications You must be signed in to change notification settings

Jimmy01240397/Chuon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chuon

Chummy Object Notation is a data interchange format and a serialization format that uses human-readable text to store and transmit data objects consisting of attribute-value pairs and arrays (or other serializable values). Or it can use the most suitable serialization format to serialize data objects consisting of attribute-value pairs and arrays (or other serializable values).

Binary Format

type Array dimension data
1 byte 1 byte data binary

length

We use Base 128 to record all length contain Array length dict length....

Base 128

If first byte is Less than 128 than it don't have next digit.

If first byte is Greater than 128 than the number is:

(byte[0]-128) + (byte[1]-128) * 128^1 + ... + (byte[n - 1]-128) * 128^{n - 1} + byte[n] * 128^n

data binary

base type

type length
byte 1 byte
sbyte 1 byte
short 2 bytes
int 4 bytes
long 8 bytes
ushort 2 bytes
uint 4 bytes
ulong 8 bytes
float 4 bytes
double 8 bytes
char 1 byte
string string_length + string bytes
bool 1 byte
object 1 byte (for data type length) + 1 byte (for data type Array dimension) + data binary (if data type length is 00 and data Array dimension is 00 that mean this data is null)
dict 1 byte (for key type length) + 1 byte (for key type Array dimension) + 1 byte (for data type length) + 1 byte (for data type Array dimension) + dict_length + data_null_tag(data element nullable except "object") + (key_binary + data_binary) * dict_length

array

Support for multidimensional arrays.

length data null tag(data element nullable except "object") datas
Base 128 (length - 1) / 8 + 1 (data_binary) * length

String Format

There are the types that you can use.

byte

byte:<number>

Array

byte[]:
{
	<Hex(don't add 0x)>
}
byte[][]:
{
	{
		1122ddff
	},
	{
		<Hex(don't add 0x)>
	}
}

short

short:<number>

Array

short[]:
{
	10000,
	-20000
}

int

int:<number>

Array

int[]:
{
	100000000,
	-200000000
}

long

long:<number>

Array

long[]:
{
	1000000000000000000,
	-200000000000000000
}

ushort

ushort:<number>

Array

ushort[]:
{
	10000,
	20000
}

uint

uint:<number>

Array

uint[]:
{
	100000000,
	200000000
}

ulong

ulong:<number>

Array

ulong[]:
{
	1000000000000000000,
	2000000000000000000
}

float

float:<floating-point number>

Array

float[]:
{
	5.5555,
	-3.14
}

double

double:<floating-point number>

Array

double[]:
{
	5.55555555555,
	-3.1415926
}

char

char:'<character>'

Array

char[]:
{
	'a',
	'n'
}

string

string:"<string>"

Array

string[]:
{
	"Hello World",
	"coming soon"
}

bool

bool:<boolean>

Array

bool[]:
{
	011001
}
bool[][]:
{
	{
		011001
	},
	{
		<many 0 or 1>
	}
}

object

object:null

Array

object[]:
{
    int:55,
    string[]:
    {
        "Hello World",
        "aaaaa"
    },
    <type>:<data>
}

dict

dict:
{
    <key type>:<data type>:
    {
        <key>,
        <data>
    }
    {
        "now",
        111
    }
}

Array

dict[]:
{
	{
		int:string:
		{
			1,
			"bad"
		}
		{
			10,
			"good"
		}
	}
	{
		<key type>:<data type>:
		{
			<key>,
			<data>
		}
		{
			"now",
			111
		}
	}
}

Usage

use Chuon

C#

using Chuon;

Java

import chuon.ChuonString;
import chuon.ChuonBinary;

Object to Chuon String

C# and Java

ChuonString chuonString = new ChuonString(objectdata);

Object to Chuon Binary

C# and Java

ChuonBinary chuonBinary = new ChuonBinary(objectdata);

Chuon String to Object

C#

Object objectdata = chuonString.ToObject();

Java

Object objectdata = chuonString.toObject();

Chuon Binary to Object

C#

Object objectdata = chuonBinary.ToObject();

Java

Object objectdata = chuonBinary.toObject();

Chuon String to Chuon Binary

C#

ChuonBinary chuonBinary = chuonString.ToChuonBinary();

Java

ChuonBinary chuonBinary = chuonString.toChuonBinary();

Chuon Binary to Chuon String

C#

ChuonString chuonString = chuonBinary.ToChuonString();

Java

ChuonString chuonString = chuonBinary.toChuonString();

Chuon String Direct serialization

C#

byte[] bytes = chuonString.ToBinaryArray(Encoding.<encoding>);

Java

byte[] bytes = chuonString.toBinaryArray(Charset.forName("<encoding name>"));

Serialize to Chuon String

C#

ChuonString chuonString = new ChuonString(stringbytes, Encoding.<encoding>);

Java

ChuonString chuonString = new ChuonString(stringbytes, Charset.forName("<encoding name>"));

Example

C#

ChounTranslator

image

Java

ChounTranslator

About

Chummy Object Notation is a data interchange format and a serialization format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other serializable values). Or it can use the most suitable serialization format to serialize data objects consisting of attribute–value pairs and array…

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published