Skip to content
/ JSOB Public

It's like if JSON was actually JS object notation instead of what it is?

Notifications You must be signed in to change notification settings

potch/JSOB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSOB - JavaScript OBject literal notation

jsob on npm

Like JSON, but a bit less of a pain. Uses an actual JS parser (acorn) to read object literal syntax (including comments!), without running the code. Only supports JSON-compatible types (numbers, boolean, strings, objects, and arrays). No need to worry about quoting keys and all that junk. If it's valid JS, it should be valid JSOB!

📦 JSOB package

This project is not particularly well tested, so maybe don't use it in prod!

Here's some JSOB:

{
  msg: 'hello!',
  'quotes': "optional but fine!",
  // this is a comment!! wowww
  'multiline support': `
    Yup! You can't use tags or substitutions,
    but otherwise go for it.
  `,
  // why not have a trailing comma while we're at it?
  last: 'property',
}

Usage

const JSOB = require('JSOB');

let obj = JSOB.parse(`{
  msg: 'hello!',
}`);

TODO

  • much, much bigger test suite
  • non-JSON serialization with options
  • self-contained parser- we don't technically need a whole JS parser so this could be a much smaller package

About

It's like if JSON was actually JS object notation instead of what it is?

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published