0.0.1 • Published 9 years ago

atom-lson v0.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

LSON: LiveScript Object Notation Parser

Same API as the JSON module, but for LiveScript objects. Also supports CSON and JSON (since LSON is a superset of them).

Uses the LiveScript parser to do the actual parsing. Will not execute code.

Install

npm install @jigsaw/lson

API

lson.parse: Given a string, returns an object.

lson.parseFile: Given a filename (extensions .lson and .json.ls are common), reads and parses it synchronously, and returns an object

lson.stringify: Given an object, returns a string (currently outputs pretty-printed JSON).

LSON format

LSON is a superset of JSON and CSON. Here is an example:

an_array: <[ an array of strings ]>
another_array: [
  'another'
  'array'
]
# we can even have comments
a_dict: {
  key: 'value'
}
a_string: 'some string'
another_string: \anotherstring

This corresponds to the following JSON:

{
  "an_array": [
    "an",
    "array",
    "of",
    "strings"
  ],
  "another_array": [
    "another",
    "array"
  ],
  "a_dict": {
    "key": "value"
  },
  "a_string": "some string",
  "another_string": "anotherstring"
}

Example

lson = require('lson')

parsed = lson.parse('''
an_array: <[ an array of strings ]>
another_array: [
  'another'
  'array'
]
# we can even have comments
a_dict: {
  key: 'value'
}
a_string: 'some string'
another_string: \\anotherstring
''')

console.log(lson.stringify(parsed))

Licence

MIT

Credits

Author: Geza Kovacs