CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
JSONSerializer.cc
Go to the documentation of this file.
1 /*
2  * JSONSerializer.cc
3  *
4  * Created on: Aug 2, 2012
5  * Author: aspataru
6  */
7 
9 
10 #include <assert.h>
11 
12 using namespace jsoncollector;
13 
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 }
26 
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 }
41 
assert(m_qm.get())
static bool serialize(JsonSerializable *pObj, std::string &output)
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 serialize(Json::Value &root) const =0
virtual void deserialize(Json::Value &root)=0
virtual std::string write(const Value &root)
Serialize a Value in JSON format.
static bool deserialize(JsonSerializable *pObj, std::string &input)
Unserialize a JSON document into a Value.
Definition: reader.h:16
Writes a Value in JSON format in a human friendly way.
Definition: writer.h:65