Socket
Socket
Sign inDemoInstall

tinysonic

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    tinysonic

a quick syntax for JSON


Version published
Weekly downloads
4K
increased by17.75%
Maintainers
1
Install size
11.0 kB
Created
Weekly downloads
 

Readme

Source

tinysonic

A quick syntax for JSON objects. Heavily inspired by jsonic, but simpler.

Install

$ npm install tinysonic --save

Example

'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(string)

Returns null if it fails parsing.

tinysonic.parse(string)

Parses the tinysonic encoded string

tinysonic.stringify(any)

Stringifies data into tinysonic string

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
  • booleans are parsed as booleans, e.g. true and false
  • you can wrap objects with { and }

License

MIT

Keywords

FAQs

Last updated on 16 Jul 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc