New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

json-san

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-san

A JSON module with Actually Useful parse errors by jshint, *and* support for callbacks! But mostly the parse errors.

latest
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

json-san

JSON-san, you much parse error!

json-san is a json module that works pretty much like the built-in JSON object EXCEPT:

  • On json.parse errors, json-san uses jshint to provide useful error messages on how to fix it!
  • json-san knows how to rock callbacks!

Install!

npm install json-san

Examples!

Here's an example of the more useful error messages:

> require("./lib/json-san").parse("[ 'foo' ]")
Error: 

      * line 1, col 4, Strings must use doublequote.

1 error

    at Object.parse (/home/josh/jsonhint/lib/json-san.js:22:13)
    at [object Context]:1:27
    at Interface.<anonymous> (repl.js:171:22)
    at Interface.emit (events.js:64:17)
    at Interface._onLine (readline.js:153:10)
    at Interface._line (readline.js:408:8)
    at Interface._ttyWrite (readline.js:585:14)
    at ReadStream.<anonymous> (readline.js:73:12)
    at ReadStream.emit (events.js:81:20)
    at ReadStream._emitKey (tty_posix.js:307:10)

See? Now you know where the mistake is!

Now here's an example of using a callback with stringify (which of course doesn't have jshint integration):

> require("./lib/json-san").stringify(["foo"], function (err, json) {
...   if (err) {
...     throw err;
...   } else {
...     console.log(json);
...   }
... });
["foo"]

Tests?

npm test

Developers! Developers! Developers!

If you like what you see (or don't quite like what you see), I heartily invite you to dig in, fork it up and git push it good.

License

MIT.

Keywords

json

FAQs

Package last updated on 03 Sep 2011

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