test
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 16 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 27 of file JSONSerializer.cc.

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

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

28 {
29  assert(pObj!=nullptr);
30 
31  Json::Value deserializeRoot;
33 
34  if (!reader.parse(input, deserializeRoot))
35  return false;
36 
37  pObj->deserialize(deserializeRoot);
38 
39  return true;
40 }
assert(m_qm.get())
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:43
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 14 of file JSONSerializer.cc.

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

Referenced by evf::RecoEventOutputModuleForFU< Consumer >::RecoEventOutputModuleForFU().

15 {
16  assert(pObj!=nullptr);
17 
18  Json::Value serializeRoot;
19  pObj->serialize(serializeRoot);
20 
21  Json::StyledWriter writer;
22  output = writer.write(serializeRoot);
23 
24  return true;
25 }
assert(m_qm.get())
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