📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

tinysonic

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tinysonic

a quick syntax for JSON

3.1.0
latest
Source
npm
Version published
Maintainers
1
Created
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.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

Keywords

json

FAQs

Package last updated on 16 Jul 2024

Did you know?

Socket

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