0.0.12 • Published 10 years ago

cirru-json v0.0.12

Weekly downloads
2
License
ISC
Repository
github
Last release
10 years ago

Cirru JSON

Converter between Cirru and JSON.

Usage

Installation:

npm install --save cirru-json

Grammar of config files:

  • Numbers: matched by /^-?\d+(\.\d+)?$/
  • Strings: :str or ":string with spaces"
  • Arrays: (array 1 (string 1)), ([] 1 2)
  • Maps: (map (:a 1))
  • Null: #null
  • Function: #lambda
  • Boolean: #true, #false
  • Undefined: #undefined

Read about Cirru interpreter for more: https://github.com/Cirru/interpreter#compact-literal-syntax

Demo:

map
  :number 1
  :string :2
  :null #null
  :bool #false
  :lambda #lambda

  :array $ array 1 2 3
  :mixed-arrat $ array 1 :2 3

  :empty-map $ map
  :map $ map (:a 1)
  :map2 $ map $ :a 2
  :nested-map $ map
    :a $ array 1 2 3
    :b $ map (:a 2) (:b 3)

Use in CoffeeScript(Shelljs is not required, but better for demo):

require 'shelljs/global'
cirruCode = cat 'config.cirru'

{parse, generate} = require 'cirru-json'
# this is parser
jsonData = parse cirruCode
# this os generator
convertBack = generate jsonData

Develop and test

node-dev test.coffee

License

MIT

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

11 years ago

0.0.8

11 years ago

0.0.7

11 years ago

0.0.6

11 years ago

0.0.5

11 years ago

0.0.4-2

11 years ago

0.0.4-1

11 years ago

0.0.4

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago