Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8413277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:53:16+00:00 2026-06-10T00:53:16+00:00

JSON really is a pain to use for local configuration files as it does

  • 0

JSON really is a pain to use for local configuration files as it does not support comments or functions, and requires incredibly verbose syntax (commas, always use " for keys). Making it very error prone, or in the case where functions are required, impossible to use.

Now I know that I could just do:

require('coffee-script')
config = require('config.coffee')

However, that requires me to do module.exports = {the data} inside config.coffee which is less than ideal. And even allows for things such as require to be exposed which can make the configuration files insecure if we do not trust them.

Has anyone found a way to read coffeescript configuration files, but keep them secure?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:53:17+00:00Added an answer on June 10, 2026 at 12:53 am

    Turns out CoffeeScript has support for the security part built in via setting the sandbox argument to true via the eval call. E.g.

    # Prepare
    fsUtil = require('fs')
    coffee = require('coffee-script')
    
    # Read
    dataStr = fsUtil.readFileSync('path').toString()
    data = coffee.eval(dataStr, {sandbox:true})
    

    The above code will read in the file data, then eval it with coffeescript in sandbox mode.

    I’ve created a nice wrapper for this called CSON which supports coffee and js files via require, and cson files via the above mechanism, and json files via the typical JSON.parse – as well as stringifying the values back to coffeescript notation. Using this, the following API is exposed:

    # Include CSON
    CSON = require('cson')
    
    # Parse a file path
    CSON.parseFile 'data.cson', (err,obj) ->  # async
    result = CSON.parseFile('data.cson')  # sync
    
    # Parse a string
    CSON.parse src, (err,obj) ->  # async
    result = CSON.parseSync(src)  # sync
    
    # Stringify an object to CSON
    CSON.stringify data, (err,str) ->  # async
    result = CSON.stringifySync(obj)  # sync
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to working with Json strings and am not really sure if the
Currently using a really simple Twisted NameVirtualHost coupled with some JSON config files to
sendng json data to another jsp page - for testing really. You enter a
I am sendng json data to another jsp page - for testing really. You
Is there a really easy way I can take an array of JSON objects
json_decode function is not part of PHP 5.1, so I cannot use it. Is
I have this json object (which i don't really know what is inside) and
I really cannot find any sample how to convert List<object> to Json format and
I have a beginner level Json question with MVC.net (I've never really used jquery
I'm having issues gathering data using JSON on the Songkick API. I'm really new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.