CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions
jsoncollector::JSONSerializer Class Reference

#include <JSONSerializer.h>

Public Member Functions

 JSONSerializer ()
 
virtual ~JSONSerializer ()
 

Static Public Member Functions

static bool deserialize (JsonSerializable *pObj, std::string &input)
 
static bool serialize (JsonSerializable *pObj, std::string &output)
 

Detailed Description

Definition at line 15 of file JSONSerializer.h.

Constructor & Destructor Documentation

jsoncollector::JSONSerializer::JSONSerializer ( )
virtual jsoncollector::JSONSerializer::~JSONSerializer ( )
virtual

Member Function Documentation

bool JSONSerializer::deserialize ( JsonSerializable pObj,
std::string &  input 
)
static

Deserializes input from a string to the JsonSerializable object

Definition at line 26 of file JSONSerializer.cc.

References jsoncollector::JsonSerializable::deserialize(), NULL, Json::Reader::parse(), and matplotRender::reader.

Referenced by jsoncollector::ObjectMerger::getDataPointDefinitionFor().

26  {
27  if (pObj == NULL)
28  return false;
29 
30  Json::Value deserializeRoot;
32 
33  if (!reader.parse(input, deserializeRoot))
34  return false;
35 
36  pObj->deserialize(deserializeRoot);
37 
38  return true;
39 }
#define NULL
Definition: scimark2.h:8
bool parse(const std::string &document, Value &root, bool collectComments=true)
Read a Value from a JSON document.
Represents a JSON value.
Definition: value.h:111
static std::string const input
Definition: EdmProvDump.cc:44
virtual void deserialize(Json::Value &root)=0
Unserialize a JSON document into a Value.
Definition: reader.h:16
bool JSONSerializer::serialize ( JsonSerializable pObj,
std::string &  output 
)
static

Serializes a JsonSerializable object to output string

Definition at line 13 of file JSONSerializer.cc.

References NULL, jsoncollector::JsonSerializable::serialize(), and Json::StyledWriter::write().

Referenced by jsoncollector::FastMonitor::outputFullHistoDataPoint().

13  {
14  if (pObj == NULL)
15  return false;
16 
17  Json::Value serializeRoot;
18  pObj->serialize(serializeRoot);
19 
20  Json::StyledWriter writer;
21  output = writer.write(serializeRoot);
22 
23  return true;
24 }
#define NULL
Definition: scimark2.h:8
Represents a JSON value.
Definition: value.h:111
virtual void serialize(Json::Value &root) const =0
virtual std::string write(const Value &root)
Serialize a Value in JSON format.
Writes a Value in JSON format in a human friendly way.
Definition: writer.h:65