JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 425
  • Score
    100M100P100Q91805F
  • License MIT

Turtle Coffee JSON

Package Exports

  • tson

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tson) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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