Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
img
lib
test
.npmignore
README.md
package.json

README.md

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.

Something went wrong with that request. Please try again.