ezEngine  Milestone 9
ezJSONReader Class Reference

This JSON reader will read an entire JSON document into a hierarchical structure of ezVariants. More...

#include <JSONReader.h>

Inheritance diagram for ezJSONReader:

Classes

struct  Element
 

Public Member Functions

ezResult Parse (ezStreamReader &pInput, ezUInt32 uiFirstLineOffset=0)
 Reads the entire stream and creates the internal data structure that represents the JSON document. Returns EZ_FAILURE if any parsing error occurred.
 
const ezVariantDictionaryGetTopLevelObject () const
 Returns the top-level object of the JSON document.
 
- Public Member Functions inherited from ezJSONParser
 ezJSONParser ()
 Constructor.
 
void SetLogInterface (ezLogInterface *pLog)
 Allows to specify an ezLogInterface through which errors and warnings are reported.
 

Protected Types

enum  ElementMode : ezInt8 { Array, Dictionary }
 

Protected Attributes

ezHybridArray< Element, 32 > m_Stack
 
bool m_bParsingError
 
ezString m_sLastName
 
- Protected Attributes inherited from ezJSONParser
ezLogInterfacem_pLogInterface
 

Additional Inherited Members

- Protected Member Functions inherited from ezJSONParser
void SetInputStream (ezStreamReader &stream, ezUInt32 uiFirstLineOffset=0)
 Resets the parser to the start state and configures it to read from the given stream.
 
bool ContinueParsing ()
 Does one parsing step. More...
 
void ParseAll ()
 Calls ContinueParsing() in a loop until that returns false.
 
void SkipObject ()
 Skips the rest of the currently open object. No OnEndArray() and OnEndObject() calls will be done for this object, cleanup must be done manually.
 
void SkipArray ()
 Skips the rest of the currently open array. No OnEndArray() and OnEndObject() calls will be done for this object, cleanup must be done manually.
 
void ParsingError (const char *szMessage, bool bFatal)
 Outputs that a parsing error was detected (via OnParsingError) and stops further parsing, if bFatal is set to true.
 

Detailed Description

This JSON reader will read an entire JSON document into a hierarchical structure of ezVariants.

The reader will parse the entire document and create a data structure of ezVariants, which can then be traversed easily. Note that this class is much less efficient at reading large JSON documents, as it will dynamically allocate and copy objects around quite a bit. For small to medium sized documents that might be good enough, for large files one should prefer to write a dedicated class derived from ezJSONParser.


The documentation for this class was generated from the following files: