Skip to content

Instantly share code, notes, and snippets.

@cheery
Created March 13, 2014 13:45
Show Gist options
  • Select an option

  • Save cheery/9528770 to your computer and use it in GitHub Desktop.

Select an option

Save cheery/9528770 to your computer and use it in GitHub Desktop.

Overview

The format is supposed to contain the same elements as JSON, and annotate it with tag strings and attribute objects.

Every value, string, number, object, array, true, false, null, can be annotated.

Special attributes

Some attributes are reserved for special purpose. For example comment, layout, diff, to name some.

Comment -attribute is meant for user, to annotate any kind of comment into the structure. It should be copied along, but otherwise should be allowed to be just plain unicode text if desired.

Layout -attribute is meant for describing unique layout for the element. Conventions for actually using this attribute aren't yet interesting.

Diff -attribute is meant for tagging differences in the structure. Diff structures themselves can be diffed.

Encoding

Strings are encoded as utf-8 obviously, but along the strings one probably wants to encode just plain bytes as well.

Numbers likely require multiple encodings. One of them is bignum, encoded in sign-magnitude -format. IEEE floats perhaps need to be available. Bigfloats? These require discussion.

Objects are basically same as dictionaries or maps. They map values to other values. They will likely share similar encoding with Arrays, that work similar to lists in python.

Constants can be encoded as-it.

Tags and annotations encode like strings and objects, they might well have just one bit difference.

Analysis

The format forms something like XML, with no limits for attributes or element contents. In this sense both JSON and XML based formats could be translated into and out of this format. This might make it an interesting alternative for the users of those formats.

It works for source maps, because JSON-like structures work just well for code if you can annotate them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment