CMS 3D CMS Logo

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 26 of file JSONSerializer.cc.

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

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

26  {
27  assert(pObj != nullptr);
28 
29  Json::Value deserializeRoot;
31 
32  if (!reader.parse(input, deserializeRoot))
33  return false;
34 
35  pObj->deserialize(deserializeRoot);
36 
37  return true;
38 }
bool parse(const std::string &document, Value &root, bool collectComments=true)
Read a Value from a JSON document.
reader
Definition: DQM.py:105
Represents a JSON value.
Definition: value.h:99
static std::string const input
Definition: EdmProvDump.cc:48
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 jsoncollector::JsonSerializable::serialize(), Json::StyledWriter::write(), and cscNeutronWriter_cfi::writer.

Referenced by evf::EvFOutputJSONWriter::EvFOutputJSONWriter(), and evf::RecoEventOutputModuleForFU< Consumer >::initRun().

14  {
15  assert(pObj != nullptr);
16 
17  Json::Value serializeRoot;
18  pObj->serialize(serializeRoot);
19 
21  output = writer.write(serializeRoot);
22 
23  return true;
24 }
virtual void serialize(Json::Value &root) const =0
Represents a JSON value.
Definition: value.h:99
std::string write(const Value &root) override
Serialize a Value in JSON format.
Writes a Value in JSON format in a human friendly way.
Definition: writer.h:63