CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 <cassert>
11 
12 using namespace jsoncollector;
13 
15  assert(pObj != nullptr);
16 
17  Json::Value serializeRoot;
18  pObj->serialize(serializeRoot);
19 
20  Json::StyledWriter writer;
21  output = writer.write(serializeRoot);
22 
23  return true;
24 }
25 
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 }
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:99
assert(be >=bs)
static std::string const input
Definition: EdmProvDump.cc:47
virtual void serialize(Json::Value &root) const =0
virtual void deserialize(Json::Value &root)=0
tuple reader
Definition: DQM.py:105
static bool deserialize(JsonSerializable *pObj, std::string &input)
std::string write(const Value &root) override
Serialize a Value in JSON format.
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:63