tson

0.0.10 • Public • Published

TSON

A Concise, permissive, TURTLE-like dialect of JSON

Synopsis

JSON can become quite noisey with all those braces and quotes:

{
    "http://example.org/johnDoe": {
        "foaf:name": "John Doe",
        "type": "String"
    }
}

What if you could omit the braces and trailing commas and some quotes? You'd get CSON:

"http://example.org/johnDoe":
    "foaf:name": "John Doe"
    type: "String"

What if you could omit the quotes around strings that contain only alphanumerics, colon and URI-safe characters?

And omit the colon separating key and value?

And replace quotes with brackets?

You get Turtleson or TSON for short, which is to JSON what Turtle is to RDF/XML: Easy to write and easy to read:

<http://example.org/johnDoe>
    foaf:name "John Doe"
    type "String"

How does it work

All the hard work is done by CSON. This module merely replaces one form of quotation mark for another and surrounds strings with quotation marks depending on the context. The result is run through CSON and returned as a JSON data structure.

Installation

As a dependency:

npm install --save tson

Globally (to use the tson CLI tool

npm install --global tson

API

The API is synchronous.

var TSON = require('tson');

From a file:

var fromFile1 = TSON.load("./fileName.tson");
var fromFile2 = TSON.loadFile ("./fileName.tson");

From a string:

var example = '<http://example.org/johnDoe>' + "\n" +
    "\t" + 'foaf:name "John Doe"' + "\n" +
    "\t" + 'type "String"' + "\n";
var fromString1 = TSON.parse(example);
var fromString2 = TSON.parseString(example);

Examples

Readme

Keywords

none

Package Sidebar

Install

npm i tson

Weekly Downloads

1

Version

0.0.10

License

MIT

Last publish

Collaborators

  • kba