Binary JSON à la Starbound

Format

  1. Let the record show that I have the worst ways to relieve my boredom.
  2. Values are in big-endian/Motorola order.
  3. An item starts with a type identifier. These are:
    1Null
    2A 64-bit double-precision float value
    3A boolean value
    4An integer value
    5A text string
    6An array or list
    7An object or map
  4. A double is in the usual industry standard format.
    2400921FB5441174447163.1415927
  5. A boolean item is followed by a single byte. If that byte equals zero, the value is false. Anything else means true
    30false
    31true
  6. An integer is in a variable-length encoded format, like a MIDI delta time, or a UTF-8 character. The most significant bit of a given part indicates if there's another to follow. Numbers can run up to 10 parts long.
  7. Signed numbers have the sign bit moved from the most to the least-significant bit for storage.
  8. Variable-length integers that signify the length of a string or the amount of items in an array or object are always unsigned. Values are always signed.
  9. A text string is encoded as a variable-length integer that counts the amount of characters, followed by that many characters.
    513Hello, world!
  10. An array is encoded as a variable-length integer that counts the amount of items in the array, followed by that many items.
    62item 0item 1
  11. An object is like an array, but each item is preceded by a text string representing that item's key.
    72key 0item 0key 1item 1
  12. There is always a single root item. This will usually be an object.
  13. Starbound data files start with an identifying header, SBVJ01, which stands for Starbound Versioned JSON, version 1, followed by an identifier text string. After the identifier there's a bool to indicate if the data is versioned. If true, there's a 32-bit version number (not variable-length), followed by the root item. The offsets in the table assume the files are indeed versioned. (thanks to kyren for clearing that up.)
    FileIdentifierData start
    *.playerPlayerEntity0x18
    *.metadataPlayerMetadata0x1A
    *.clientcontextClientContext0x19
    universe.datUniverseSettings0x1C
  14. Shipworlds, chunks, and worlds are a different beast entirely.

Online Decoder

Or drop a file here.
//Results go here.

Comments

comments powered by Disqus