node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

coffee-son

CoffeeSON

Goals:

  • A description of how to format JSON data as literals in CoffeeScript. (started)
  • A tool for rendering JSON data as CoffeeScript for inclusion in CoffeeScript files. (just started)

Note: This is not intended as a replacement for JSON, but a tool for using it with CoffeeScript. It's not a serialization format, it's an editing format. Note the inclusion of module.exports (a replacement format would include a parser).

Example

CoffeeScript module with a literal:

module.exports =
  spans:
    [
      text: ''
    ,
      text: 'link'
      url: 'https://github.com/jsonista/coffee-literals'
    ,
      text: ' to this repo'
    ]
  mustache:
    '''
    <div>
    {{ spans }}
    </div>
    '''

JSON:

{
  "spans":
  [
    {
      "text": ""
    },
    {
      "text": "link",
      "url": "https://github.com/jsonista/coffee-literals"
    },
    {
      "text": " to this repo"
    }
  ],
  "mustache": "<div>\n{{ spans }}\n</div>"
}