CMS 3D CMS Logo

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 {
16  assert(pObj!=nullptr);
17 
18  Json::Value serializeRoot;
19  pObj->serialize(serializeRoot);
20 
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 
virtual void serialize(Json::Value &root) const =0
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:45
virtual void deserialize(Json::Value &root)=0
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:65