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

◆ JSONSerializer()

jsoncollector::JSONSerializer::JSONSerializer ( )

◆ ~JSONSerializer()

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

Member Function Documentation

◆ deserialize()

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 cms::cuda::assert(), jsoncollector::JsonSerializable::deserialize(), input, 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 }
reader
Definition: DQM.py:105
Represents a JSON value.
Definition: value.h:99
assert(be >=bs)
static std::string const input
Definition: EdmProvDump.cc:50
virtual void deserialize(Json::Value &root)=0
Unserialize a JSON document into a Value.
Definition: reader.h:16

◆ serialize()

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 cms::cuda::assert(), jsoncollector::JsonSerializable::serialize(), and convertToRaw::writer.

Referenced by evf::GlobalEvFOutputJSONDef::GlobalEvFOutputJSONDef().

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 }
Represents a JSON value.
Definition: value.h:99
assert(be >=bs)
virtual void serialize(Json::Value &root) const =0
Definition: output.py:1
Writes a Value in JSON format in a human friendly way.
Definition: writer.h:63