npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jsonic/jsonic-next

v2.14.0

Published

A dynamic JSON parser that isn't strict and can be customized.

Downloads

23,802

Readme

jsonic

NOTE: PREVIEW VERSION OF NEXT RELEASE

A JSON parser for JavaScript that isn't strict. Also, it's very very extensible.

a:1,foo:bar{"a": 1, "foo": "bar"}

Site | Docs | FP Guide | Contributing | Wiki | Code of Conduct | Twitter | Chat

npm version dependencies Status

Quick start

Install:

> npm install jsonic

Node.js:

const Jsonic = require('jsonic')
console.log(Jsonic('a:b'))  // prints {a:'b'}

TypeScript:

import { Jsonic } from 'jsonic'
console.log(Jsonic('a:b'))  // prints {a:'b'}

Browser:

<script src="jsonic.min.js"></script>
<script>
console.log(Jsonic('a:b'))  // prints {a:'b'}
</script>

(Although in the real world you'll probably be packaging jsonic as a dependency with webpack or similar.)

What can jsonic do?

All of the examples below parse beautifully to {"a": 1, "b": "B"}.

short and sweet

a:1,b:B

no commas, no problem

a:1
b:B

comments are cool

a:1
// a:2
# a:3

/* b wants 
 * to B
 */
b:B

strings and things

{ "a": 100e-2, '\u0062':`\x42`, }

The syntax of jsonic is just easy-going JSON:

  • simple no-quotes-needed property names: {a:1}{"a": 1}
  • implicit top level (optional): a:1,b:2{"a": 1, "b": 2}, a,b["a", "b"]
  • graceful trailing commas: a:1,b:2,{"a": 1, "b": 2}, a,b,["a", "b"]
  • all the number formats: 1e1 === 0xa === 0o12 === 0b1010

But that is not all! Oh, no. That is not all...

This:

# Merge, baby, merge!
cat: { hat: true }
cat: { fish: null }
cat: who: ['sally', 'me']
  
# Who needs quotes anyway?
holds up: [
  cup and a cake,

  `TWO books!
   the fish!`,

  '''
  ship!
  dish!
  ball!
  '''
  ]
}

parses into this:

{
  "cat": {
    "hat": true,
    "fish": null,
    "who": ["sally","me"]
  },
  
  "holds up": [
    "cup and a cake",
    "TWO books!\n   the fish!",
    "ship!\ndish!\nball!"
  ]
}

Meaning you also get:

  • quotes can be single or double ': 'a',"b"['a', 'b']
  • quotes are optional, even with spaces: {a: cup cake }{"a": "cup cake"}
  • object merging: a:{b:1},a:{c:2}{"a": {"b": 1, "c": 2}}
  • object construction: a:b:1,a:c:2{"a": {"b": 1, "c": 2}}
  • multi-line strings:
`a
b` 

"a\nb"

  • indent-adjusted strings:
  '''
  a
  b
  '''

"a\nb"

And we haven't even begun to talk about all the fun stuff you can do with options and plugins, including support for multiple files, CSV (or TSV), and dynamic content.

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

Usage

Breaking Changes

  • unterminated strings?