cxxtools::JsonOObject< ObjectType > Class Template Reference

Wrapper object to easily print serializable objects as json to a output stream. More...

#include <cxxtools/json.h>

Inheritance diagram for cxxtools::JsonOObject< ObjectType >:
cxxtools::JsonIOObject< ObjectType >

Public Member Functions

 JsonOObject (const ObjectType &object, bool beautify=false)
 Constructor.
JsonOObjectbeautify (bool sw)
 Sets the formatting for json.
bool beautify () const
JsonOObjectplainkey (bool sw)
bool plainkey () const
const ObjectType & object () const

Detailed Description

template<typename ObjectType>
class cxxtools::JsonOObject< ObjectType >

Wrapper object to easily print serializable objects as json to a output stream.

JsonOObject is a little wrapper which makes it easy to output serializable objects into a ostream. For this the JsonOObject expects a reference to the wrapped object and has a output operator for a std::ostream, or actually a std::basic_ostream, which prints the object in json format.

Example:

std::vector<unsigned> v;
v.push_back(4);
v.push_back(17);
v.push_back(12);
std::cout << cxxtools::Json(v).beautify(true) << std::endl;

Constructor & Destructor Documentation

template<typename ObjectType>
cxxtools::JsonOObject< ObjectType >::JsonOObject ( const ObjectType &  object,
bool  beautify = false 
)
inlineexplicit

Constructor.

Needs the wrapped object. Optionally a flag can be passed whether the json should be nicely formatted.

Member Function Documentation

template<typename ObjectType>
JsonOObject& cxxtools::JsonOObject< ObjectType >::beautify ( bool  sw)
inline

Sets the formatting for json.

If the passed flag is true, enables nice formatting, otherwise disables it. The json is printed then without whitespace

template<typename ObjectType>
bool cxxtools::JsonOObject< ObjectType >::beautify ( ) const
inline
template<typename ObjectType>
const ObjectType& cxxtools::JsonOObject< ObjectType >::object ( ) const
inline
template<typename ObjectType>
JsonOObject& cxxtools::JsonOObject< ObjectType >::plainkey ( bool  sw)
inline
template<typename ObjectType>
bool cxxtools::JsonOObject< ObjectType >::plainkey ( ) const
inline

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