Class: UrisonParser

UrisonParser

new UrisonParser(errorHandleropt)

Creates a new UrisonParser instance.

All errors in this class result in a console error message rather than an exception. To work with occurring errors, define an errorCallback for the constructor and throw errors from there if needed.

Parameters:
Name Type Attributes Default Description
errorHandler function <optional>
null

function to call in case parsing fails, receives the error message and the character index as parameters

Source:

Methods

parse(risonString) → {Object|Array|undefined}

Parses a Rison string into a JSON object. Resets internal parsing info, like parsing index, to start new parsing process.

Parameters:
Name Type Description
risonString String

the string to parse

Source:
Returns:
the parsed JSON object or undefined, in case parsing failed
Type
Object | Array | undefined
Example
(new UrisonParser()).parse('(key1:value,key2:!t,key3:!(!f,42,!n))')
=> {key1 : 'value', key2 : true, key3 : [false, 42, null]}