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 
8 #include "../interface/JSONSerializer.h"
9 
10 using namespace jsoncollector;
11 using std::string;
12 
14  if (pObj == NULL)
15  return false;
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  if (pObj == NULL)
28  return false;
29 
30  Json::Value deserializeRoot;
32 
33  if (!reader.parse(input, deserializeRoot))
34  return false;
35 
36  pObj->deserialize(deserializeRoot);
37 
38  return true;
39 }
static bool serialize(JsonSerializable *pObj, std::string &output)
#define NULL
Definition: scimark2.h:8
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