cppexpose  1.0.0.b785e04f23b8
C++ library for type introspection, reflection, and scripting interface
Public Types | Static Public Member Functions | List of all members
cppexpose::JSON Class Reference

JSON tools. More...

#include <cppexpose/include/cppexpose/json/JSON.h>

Public Types

enum  OutputMode { Compact = 0, Beautify }
 JSON output mode. More...
 

Static Public Member Functions

static std::string stringify (const Variant &root, OutputMode outputMode=Compact)
 Linearize JSON to string. More...
 
static void stringify (std::ostream &stream, const Variant &root, OutputMode outputMode=Compact)
 Linearize JSON to string. More...
 
static bool load (Variant &root, const std::string &filename)
 Load JSON from file. More...
 
static bool parse (Variant &root, const std::string &document)
 Parse JSON from string. More...
 

Detailed Description

JSON tools.

Member Enumeration Documentation

JSON output mode.

Enumerator
Compact 

Create JSON without indentation and newlines.

Beautify 

Create better readable JSON with indentation and newlines.

Member Function Documentation

static std::string cppexpose::JSON::stringify ( const Variant &  root,
OutputMode  outputMode = Compact 
)
static

Linearize JSON to string.

Parameters
[in]rootVariant value
[in]outputModeJSON output mode
Returns
JSON string
static void cppexpose::JSON::stringify ( std::ostream &  stream,
const Variant &  root,
OutputMode  outputMode = Compact 
)
static

Linearize JSON to string.

Parameters
[in]streamStream to write results to
[in]rootVariant value
[in]outputModeJSON output mode
static bool cppexpose::JSON::load ( Variant &  root,
const std::string &  filename 
)
static

Load JSON from file.

Parameters
[out]rootOutput variant
[in]filenameFilename of JSON file
Returns
'true' if all went fine, 'false' on error
static bool cppexpose::JSON::parse ( Variant &  root,
const std::string &  document 
)
static

Parse JSON from string.

Parameters
[out]rootOutput variant
[in]documentJSON string
Returns
'true' if all went fine, 'false' on error

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