fjson

0.2.1b • Public • Published

FunkyJSON

FunkyJSON (FJSON) is an extension of the JSON that allows for the transmission of functions via JSON. The need to serialize functions into JSON was necessary to solve certains issues we were having so we developed a mean to serialize functions and parse them. FJSON is a very simple library.

How It Works

FJSON takes a function and converts into a serializable object. For example, assume the object:

var hello = function(name) {
  console.log(name);
}; 

Would be converted to the following serializable object:

{
  "FUNCTION": true,
  "params": [ "name" ],
  "body": "console.log(name);"
}   

For regular expressions it will take the following expression: /apple|banana/gi and parse it into the serializable object:

{
  "REGEXP": true,
  "source": "apple|banana",
  "flags": "gi"
}

How to Use It

Installation

Install via NPM easily with npm install fjson or globally with npm install -g fjson

Usage

Once installed require in your code file easily: var FJSON = require("fjson");

From here you can use the variable you stored the library into (in the above example it's FJSON) or you can use the same functions on the JSON object.

Use FJSON.funkify(obj); to serialize the object as a string (including functions) and use FJSON.unfunkify(str); to convert a FJSON string into an object.

FJSON should be usable in a browser but this is untested.

Author

Brandon Buck (brandon.buck@logicnation.us)

License

AGPL v3

This software is licensed under the Affero General Public License which can be found here.

Readme

Keywords

none

Package Sidebar

Install

npm i fjson

Weekly Downloads

5

Version

0.2.1b

License

none

Last publish

Collaborators

  • LogicNation