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).
type | Array dimension | data |
---|---|---|
1 byte | 1 byte | data binary |
We use Base 128 to record all length contain Array length dict length....
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
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 |
Support for multidimensional arrays.
length | data null tag(data element nullable except "object") | datas |
---|---|---|
Base 128 | (length - 1) / 8 + 1 | (data_binary) * length |
There are the types that you can use.
byte:<number>
byte[]:
{
<Hex(don't add 0x)>
}
byte[][]:
{
{
1122ddff
},
{
<Hex(don't add 0x)>
}
}
short:<number>
short[]:
{
10000,
-20000
}
int:<number>
int[]:
{
100000000,
-200000000
}
long:<number>
long[]:
{
1000000000000000000,
-200000000000000000
}
ushort:<number>
ushort[]:
{
10000,
20000
}
uint:<number>
uint[]:
{
100000000,
200000000
}
ulong:<number>
ulong[]:
{
1000000000000000000,
2000000000000000000
}
float:<floating-point number>
float[]:
{
5.5555,
-3.14
}
double:<floating-point number>
double[]:
{
5.55555555555,
-3.1415926
}
char:'<character>'
char[]:
{
'a',
'n'
}
string:"<string>"
string[]:
{
"Hello World",
"coming soon"
}
bool:<boolean>
bool[]:
{
011001
}
bool[][]:
{
{
011001
},
{
<many 0 or 1>
}
}
object:null
object[]:
{
int:55,
string[]:
{
"Hello World",
"aaaaa"
},
<type>:<data>
}
dict:
{
<key type>:<data type>:
{
<key>,
<data>
}
{
"now",
111
}
}
dict[]:
{
{
int:string:
{
1,
"bad"
}
{
10,
"good"
}
}
{
<key type>:<data type>:
{
<key>,
<data>
}
{
"now",
111
}
}
}
using Chuon;
import chuon.ChuonString;
import chuon.ChuonBinary;
ChuonString chuonString = new ChuonString(objectdata);
ChuonBinary chuonBinary = new ChuonBinary(objectdata);
Object objectdata = chuonString.ToObject();
Object objectdata = chuonString.toObject();
Object objectdata = chuonBinary.ToObject();
Object objectdata = chuonBinary.toObject();
ChuonBinary chuonBinary = chuonString.ToChuonBinary();
ChuonBinary chuonBinary = chuonString.toChuonBinary();
ChuonString chuonString = chuonBinary.ToChuonString();
ChuonString chuonString = chuonBinary.toChuonString();
byte[] bytes = chuonString.ToBinaryArray(Encoding.<encoding>);
byte[] bytes = chuonString.toBinaryArray(Charset.forName("<encoding name>"));
ChuonString chuonString = new ChuonString(stringbytes, Encoding.<encoding>);
ChuonString chuonString = new ChuonString(stringbytes, Charset.forName("<encoding name>"));