Parsing JSON data

In its easiest way, parsing JSON data is as trivial as invoking the static JAULA::Parser::parseStream() method giving a stream as its only input parameter.

This method will return (in case that parsing can be performed) a pointer to memory taken from the heap and containing a data value describing the JSON data read.

As a consequence of the JSON specification, this data value must be an array or an object that, in terms of the JAULA API is represented as a JAULA::Value_Complex type pointer returned that basically means that the data value can be iterated in order to get its components.

Once the parsing method returns, the data value allocated memory is no longer managed by the library and it will be up to the user when and how t will be fred in order to avoid memory leaks due to unfred memory or segmentation faults if some part of the program tries to use a chunk of memory fred by a former operation.

One way for automating memory management is by means of the std::auto_ptr template and this approach has been used in this example (and in library implementation as well). In case you need some more info about auto pointers, look at auto_ptr in C++ Annotations or look in the Related Documents section for more info.