https://github.com/potch/jsob
It's like if JSON was actually JS object notation instead of what it is?
https://github.com/potch/jsob
Last synced: 12 months ago
JSON representation
It's like if JSON was actually JS object notation instead of what it is?
- Host: GitHub
- URL: https://github.com/potch/jsob
- Owner: potch
- Created: 2019-04-02T21:33:10.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T20:46:16.000Z (over 3 years ago)
- Last Synced: 2025-07-06T09:45:00.746Z (12 months ago)
- Language: JavaScript
- Homepage:
- Size: 451 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JSOB - JavaScript OBject literal notation
[](https://www.npmjs.com/package/jsob)
Like JSON, but a bit less of a pain. Uses an actual JS parser ([acorn](https://github.com/acornjs/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](https://www.npmjs.com/package/jsob)
**This project is not particularly well tested, so maybe don't use it in prod!**
Here's some JSOB:
```js
{
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
```js
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