|
Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
|
JVal represents a value in a JSON tree.
An instance of the JParserValFact creates a syntax tree out of the parsed JSON data. An instance of JVal is one node in the tree. Method JParserValFact::getFirstVal returns the tree root element.
Most methods in this class take a JErr as argument. The methods set an error code if the JVal is not of the expected type or any other errors occur.
Always check the supplied JErr as well as the returned value: zero/NULL can also be valid JSON results. Format extraction and add operations stop for an existing error, but individual accessors and setters do not uniformly do so. Some C functions accept NULL and record an error; direct accessor macros require non-NULL nodes. Never call a C++ member through a NULL pointer.
Nodes, strings, and member names belong to their tree until explicitly detached. Use the matching node and data allocators when releasing detached storage.
See the JSON tutorial, section Using JParserValFact , for examples on how to use JVal.
#include <JVal.h>
Public Member Functions | |
| JVType | getType () |
| JVal * | vget (JErr *err, const char **fmt, va_list *argList) |
| Extract values as for get(), using mutable format and argument cursors. More... | |
| JVal * | get (JErr *err, const char *fmt,...) |
| Get any type of value(s) from a JVal node or JVal tree. More... | |
| S32 | getInt (JErr *e) |
| Convert a numeric, boolean, or null node to S32. More... | |
| void | setInt (JErr *e, S32 v) |
| Replace a scalar value and set its type. More... | |
| S64 | getLong (JErr *e) |
| Convert a numeric, boolean, or null node to S64. More... | |
| void | setLong (JErr *e, S64 v) |
| Replace a scalar value and set its type. More... | |
| double | getDouble (JErr *e) |
| Convert a numeric, boolean, or null node to double. More... | |
| void | setDouble (JErr *e, double v) |
| Replace a scalar value and set its type. More... | |
| BaBool | getBoolean (JErr *e) |
| Read a boolean or null node. More... | |
| void | setBoolean (JErr *e, BaBool v) |
| Replace a scalar value and set its type. More... | |
| void | setNull (JErr *e) |
| Replace a scalar value with JSON null. More... | |
| const char * | getString (JErr *e) |
| Access a string without transferring ownership. More... | |
| size_t | getStringLen () |
| void | setString (JErr *e, char *v) |
| Store a string pointer without copying it and set the node's type. More... | |
| char * | manageString (JErr *e) |
| Detach a string's storage, leaving a String node with NULL data and zero length. More... | |
| const char * | getName () |
| size_t | getNameLen () |
| char * | manageName () |
| Detach the member name and clear its pointer/length in the node. More... | |
| JVal * | getNextElem () |
| JVal * | getObject (JErr *e) |
| Access the first child of an object node. More... | |
| JVal * | getArray (JErr *e) |
| Access the first child of an array node. More... | |
| JVal * | getJ (JErr *e) |
| Access the first child of an object or array node. More... | |
| JVal * | manageJ (JErr *e) |
| Detach all children from an object/array, leaving the container empty. More... | |
| S32 | getLength (JErr *e) |
| Count immediate children of this object/array. More... | |
| bool | isObjectMember () |
| int | unlink (JVal *child) |
| Remove one immediate child without destroying it. More... | |
| int | addMember (JErr *e, const char *memberName, JVal *child, AllocatorIntf *dAlloc) |
| Prepend a child to an object. More... | |
| int | add (JErr *e, JVal *child) |
| Prepend a child to an array. More... | |
| void | terminate (AllocatorIntf *vAlloc, AllocatorIntf *dAlloc) |
| Free this node, all descendants, and all following siblings recursively. More... | |