JSONKey
Promised json key search.
Usage
In Browser
Use bower.
bower isntall jsonkey
JSONKey
will be installed to global.
In Node.js
Use npm.
npm isntall jsonkey
var JSONKey = ;
API
Constructor
var parser = /*timeout: Number*/;
Create a json parser.
params
-
timeout
:Number :Optional(Default 100)All promise created by
key
method will be rejected when specified milliseconds was past before key was found.
key
var findingName = parser;
Create promise for value corresponding to specified key.
params
-
key
:String :RequiredYou can use dot notation for nested object and brackets for array index.
example
parser ; parser parser var jsonString = JSON;parser;// "LastName is aaa"// "Fist favorite is book"// "address is not found"
filter, pipe, recovery, map, reduce, etc
promise
generated by key
function is chain-able.
So easily create function chain as functional programming style.
See also APIs of Promisechain.
parser; var jsonString = JSON;parser;// => "TotalPrice is: 16"
on, once, addListener, etc
JSONKey
inherits Node.js's build in EventEmitter
.
So parser works as EventEmitter
itself.
Each key in jsonString will be emitted as event.
example
var parser = ;var parser; var jsonString = JSON;parser;
Development
Install Node.js and NPM.
git clone git://github.com/georegeosddev/jsonkey.gitcd jsonkeynpm installnpm run-script build
Licence
MIT