Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mcollina/tinysonic
a quick syntax for JSON object
https://github.com/mcollina/tinysonic
Last synced: 2 days ago
JSON representation
a quick syntax for JSON object
- Host: GitHub
- URL: https://github.com/mcollina/tinysonic
- Owner: mcollina
- License: mit
- Created: 2016-08-18T13:52:36.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-07-16T14:30:03.000Z (5 months ago)
- Last Synced: 2024-12-13T08:14:11.521Z (10 days ago)
- Language: JavaScript
- Homepage:
- Size: 44.9 KB
- Stars: 57
- Watchers: 4
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tinysonic
A quick syntax for JSON objects. Heavily inspired by
[jsonic](https://github.com/rjrodger/jsonic), but simpler.## Install
```
$ npm install tinysonic --save
```## Example
```js
'use strict'var tinysonic = require('tinysonic')
const encoded = tinysonic.stringify({
hello: 'world',
my: {
world: 'data'
}
})console.log('Encoded: ', encoded)
// Encoded: 'hello:world,my:{world:data}'const decoded = tinysonic.parse(encoded)
console.log('Decoded: ', decoded)
// Decoded: { hello: 'world', my: { world: 'data' } }```
## API
### tinysonic.parse(string/buffer)
Parses a tinysonic encoded string. Returns `null` if it fails parsing.### tinysonic.stringify(object)
Stringifies a js object into a tinysonic string. Returns `null` on error.### tinysonic(string/buffer)
Alternative for `tinysonic.parse()`## Syntax
The full syntax is:
* each key value pair is separated by `:`
* multiple pairs are separated by `,`
* each key or value are trimmed for spaces
* numbers are parsed as numbers
* null are parsed as `null`
* booleans are parsed as booleans, e.g. `true` and `false`
* you can wrap objects with `{` and `}`## License
MIT