Skip to content

Instantly share code, notes, and snippets.

@rezan
Created August 2, 2017 20:44
Show Gist options
  • Save rezan/e58533a35e811f9934ad28c92a374299 to your computer and use it in GitHub Desktop.
Save rezan/e58533a35e811f9934ad28c92a374299 to your computer and use it in GitHub Desktop.
JSON prototype
$Module json 3 JSON parsing
DESCRIPTION
===========
JSON parsing
$Function VOID parse(PRIV_TASK, STRING json)
Parse the JSON string.
$Function STRING get(PRIV_TASK, STRING search, STRING error, BOOL json_string = 0)
Get the JSON node using the search string. If not found, error is returned.
If the result is a string and json_string = true, return a JSON encoded string.
$Function INT length(PRIV_TASK)
Get the length of the root JSON node.
For objects, its the number of keys. For arrays, its the number of elements.
For everything else, its 0.
$Function STRING type(PRIV_TASK)
Get the root JSON node type.
$Function BOOL is_valid(PRIV_TASK)
Is this valid JSON?
$Function BOOL is_error(PRIV_TASK)
Is this invalid JSON?
$Function BOOL is_object(PRIV_TASK)
Is this a JSON object?
$Function BOOL is_array(PRIV_TASK)
Is this a JSON array?
$Function BOOL is_string(PRIV_TASK)
Is this a JSON string?
$Function BOOL is_number(PRIV_TASK)
Is this a JSON number?
$Function BOOL is_true(PRIV_TASK)
Is this a JSON true?
$Function BOOL is_false(PRIV_TASK)
Is this a JSON false?
$Function BOOL is_null(PRIV_TASK)
Is this a JSON null?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment