Parse documents consisting of a JSON header followed by a body.
JavaScript Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.gitignore
README.md
index.js
package.json
runtests

README.md

json-header

A simple protocol and script that interprets a document as consisting of a json header and a body. Use the parse function to parse a document into the header and body.

Example node session:

> jh=require('./index.js');
{ parse: [Function] }
> jh.parse('{"key":"value","date":"2013-07-10 CST"}body of the document',jh.dateReviver);
{ header: 
   { key: 'value',
     date: 'Wed Jul 10 2013 14:35:03 GMT-0500 (CDT)' },
  body: 'body of the document' }

This software is used in my blog, ryanxcharles.com, but could be used in any case where documents that have a header with meta-information and a body. For instance, hypothetically, you could implement something like HTTP or SMTP with JSON in the header using json-header.