Rationale and Objectives
UBJSON is a proposed successor to BSON, BJSON and others. UBJSON has the following goals: * Complete compatibility with the JSON specification – there is a 1:1 mapping between standard JSON and UBJSON. * Ease of implementation – only including data types that are widely supported in popular programming languages so that there are no problems with certain languages not being supported well. * Ease of use – it can be quickly understood and adopted. * Speed and efficiency – UBJSON uses data representations that are (roughly) 30% smaller than their compacted JSON counterparts and are optimized for fast parsing. Streamed serialisation is supported, meaning that the transfer of UBJSON over a network connection can start sending data before the final size of the data is known.Data types and syntax
UBJSON data can be either a ''value'' or a ''container''.Value types
UBJSON uses a single binary tuple to represent all JSON value types: type ength ata Each element in the tuple is defined as:type
The type is a 1-byteZ
* N
- no operation, to be ignored by the receiving end
* Boolean types: true (T
) and false (F
)
* Numeric types: i
), uint8 (U
), int16 (I
), int32 (l
), L
), d
), float64 (D
), and high-precision (H
)
* C
* S
High-precision numbers are represented as an arbitrarily long, UTF-8 string-encoded numeric value.
length (optional)
The length is an integer number (e.g. uint8, or int64) encoding the size of the data payload in bytes. It is used for strings, high-precision numbers and optionally containers. They are omitted for other types. Length is encoded following the same convention as integers, thus including its own type. For example, the stringhello
is encoded as S
,U
,0x05,h
,e
,l
,l
,o
.
data (optional)
A sequence of bytes representing the actualContainer types
Similarly to JSON, UBJSON defines two container types: ''array'' and ''object''. Arrays are ordered sequences of elements, represented as a followed by zero or more elements of value and container type and a trailing ">/code> followed by zero or more elements of value and container type and a trailing
/code>.
Objects are labeled sets of elements, represented as a
. Each key is a string with the S
character omitted, and each "value" can be any element of value or container type.
Alternatively, arrays and objects may indicate the number of elements they contain as #
followed by an integer number before their first element, in which case the trailing ]
or }
is omitted. Additionally, if all elements have the same type, the types can be omitted and replaced by a single $
followed by the type, in which case the element count must follow immediately. For example, the array a","b","c"/nowiki> may be represented as ,$
,C
,#
,U
,0x03,a
,b
,c
.
Binary data
While there is no explicit binary type, binary data is stored in a Strong and weak typing">strongly typed array of uint8 values. This ensures binary efficiency while maintaining compatibility with JSON, even though JSON has no direct support for binary data.
Representation
The MIME type 'application/ubjson' is recommended, as is the file extension '.ubj' when stored in a file-system.
Software support
* Teradata Database
* The Wolfram Language
The Wolfram Language ( ) is a general multi-paradigm programming language developed by Wolfram Research. It emphasizes symbolic computation, functional programming, and rule-based programming and can employ arbitrary structures and data. It is ...
introduced support for UBJSON in 2017, with version 11.1 of the language.
See also
* Comparison of data serialization formats
* JSON
JSON (JavaScript Object Notation, pronounced ; also ) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other s ...
* CBOR
* Smile
A smile is a facial expression formed primarily by flexing the muscles at the sides of the mouth. Some smiles include a contraction of the muscles at the corner of the eyes, an action known as a Duchenne smile.
Among humans, a smile expresses d ...
(binary JSON)
* Protocol Buffers
* Action Message Format
* Apache Thrift
* MessagePack
* Document-oriented database
A document-oriented database, or document store, is a computer program and data storage system designed for storing, retrieving and managing document-oriented information, also known as semi-structured data.
Document-oriented databases are one ...
(e.g. MongoDB
MongoDB is a source-available cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas. MongoDB is developed by MongoDB Inc. and licensed under the Ser ...
)
* Abstract Syntax Notation One
Abstract Syntax Notation One (ASN.1) is a standard interface description language for defining data structures that can be Serialization, serialized and deserialized in a cross-platform way. It is broadly used in telecommunications and computer n ...
(ASN.1)
* Wireless Binary XML (WBXML)
* Efficient XML Interchange
References
External links
*
{{Data Exchange
Data serialization formats