atom-lson

0.0.1 • Public • Published

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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.12latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.12

Package Sidebar

Install

npm i atom-lson

Weekly Downloads

2

Version

0.0.1

License

MIT

Last publish

Collaborators

  • jigsaw