TXON – Text Object Notation – is a minimal format for embedding structured data into any text readably and unobtrusively. It is like a specialised reduction of JSON to more closely fit general text (or like a variant of INI to more closely fit nested objects).
A Python implementation to read and write TXON, and translate to/from JSON, is supplied. The core is less than 100 lines of basic code, and could be easily translated.
TXON is a nestable key-value syntax structure: like a simplified JSON with only strings and objects, and a different textual representation. The basic structure is:
name:`value`
This can be nested:
name1:` name2:`nested value` `
And, names are optional and need not be unique, text content may be included alongside terms, and any layout is allowed:
references:`
JSON – :`http://json.org/`
Scribe – :`http://en.wikipedia.org/wiki/Scribe_(markup_language)`
INI – :`http://en.wikipedia.org/wiki/INI_file`
Lua – :`http://lua.org/`
`
Outside an expression, only the sequence of : followed by ` is special and not generally allowed (this pair is what makes TXON terms findable in text). Inside an expression, ` is special and not generally allowed, unless escaped with \ . Note that this rudimentary escaping implies a certain feature: strings cannot end with a \ .
term = [name] ":`" value "`"
value = *(string / term)
name = 1*(non-blank UTF8 char, except `)
string = 1*(UTF8 char, except ` unless escaped with \)
term = [name], ":`", value, "`" ;
value = {string | term}
name = non-blank UTF8 chars, except `
string = UTF8 chars, except ` unless escaped with \
Download:` http://www.hxa.name/txon/txon.py.txt `
readTxon : text with TXON → native data structurewriteTxon : native data structure → string of TXONtranslateTxonToJson : text with TXON → string of JSONtranslateJsonToTxon : string of JSON → string of TXONtext with TXON → string of JSONstring of JSON → string of TXONWhy? – A little experiment to make a form of ‘digital punctuation’: a normal textual convention that is also easily parseable. (Printed text has, over the centuries, developed various metadata-like conventions, for sentences, sections, headings, etc. – so why not have something fitted to modern tech, something more machine readable . . .)
Influences:
@name(value), move the @ next to the ( – which is also like INI: name="value".{ }.And, the two chars, : and `, are chosen to be:
DC:`
title:`TXON - Text Object Notation`
creator:`Harrison Ainsworth / HXA7241`
date:`2010-04-02`
date:`2010-09-13`
description:`Definition of a minimal format for embedding structured data
into any text readably and unobtrusively.`
subject:`data format, text, JSON, software, python`
language:`en-GB`
type:`technical article`
relation:`http://www.hxa.name/`
identifier:`http://www.hxa.name/txon/`
rights:`Creative Commons BY-SA 3.0 License.`
rights:`MIT License.`
`