Type Reference

The table below is a quick-reference for folks working closely with the Universal Binary JSON format that want all the information at their finger tips:

Type Size Marker Length Data Payload
Value Types
null  1-byte  Z  No  No
no-op  1-byte  N  No  No
true  1-byte  T  No  No
false  1-byte  F  No  No
int8  2-bytes  i  No  Yes
uint8  2-bytes  U  No  Yes
int16  3-bytes  I  No  Yes
int32  5-bytes  l  No  Yes
int64  9-bytes  L  No  Yes
float32  5-bytes  d  No  Yes
float64  9-bytes  D  No  Yes
high-precision number  1-byte + int num val + string byte len  H  Yes  Yes (if non-empty)
char  2-bytes  C  No  Yes
string  1-byte + int num val + string byte len  S  Yes  Yes (if non-empty)
Container Types
array**  2+ bytes  [ and ]  Optional  Yes (if non-empty)
object**  2+ bytes  { and }  Optional  Yes (if non-empty)

** See container optimized format for details.


Below is an example of what a common JSON response would look like in UBJSON. This particular example was taken from the GitHub developer docs.

JSON Response

  "login": "octocat",
  "id": 1,
  "avatar_url": "https://github.com/images/error/octocat_happy.gif",
  "gravatar_id": "somehexcode",
  "url": "https://api.github.com/users/octocat",
  "name": "monalisa octocat",
  "company": "GitHub",
  "blog": "https://github.com/blog",
  "location": "San Francisco",
  "email": "octocat@github.com",
  "hireable": false,
  "bio": "There once was...",
  "public_repos": 2,
  "public_gists": 1,
  "followers": 20,
  "following": 0,
  "html_url": "https://github.com/octocat",
  "created_at": "2008-01-14T04:33:35Z",
  "type": "User",
  "total_private_repos": 100,
  "owned_private_repos": 100,
  "private_gists": 81,
  "disk_usage": 10000,
  "collaborators": 8,
  "plan": {
    "name": "Medium",
    "space": 400,
    "collaborators": 10,
    "private_repos": 20

UBJSON Response (using block-notation)

    [i][4][name][S][i][16][monalisa octocat]
    [i][8][location][S][i][13][San Francisco]
    [i][3][bio][S][i][17][There once was...]