🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

cirru-json

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cirru-json

Convert between Cirru and JSON

latest
npmnpm
Version
0.0.12
Version published
Weekly downloads
13
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

cirru

FAQs

Package last updated on 31 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts