Commit 0f2552ad authored by Karl Herbig's avatar Karl Herbig

Add default cast operators and stringFromObject method

parent bf599a4a
......@@ -14,6 +14,7 @@ class JsonPP
static Value arrayFromString(std::string jsonArrayString);
public:
static Value objectFromString(std::string jsonString);
static std::string stringFromObject ( Object& jsonObject );
};
}
......
......@@ -60,6 +60,13 @@ public:
Value& operator[](const std::string& key);
Value& operator[](const int key);
explicit operator double() const { return _dobValue; }
explicit operator int() const { return _intValue; }
explicit operator bool() const { return _bolValue; }
explicit operator std::string () const { return _strValue; }
operator Object () const { return _objValue; }
operator Array () const { return _aryValue; }
friend std::ostream& operator<<(std::ostream& os, const Value& val);
ValueType type();
......
#include "JsonPP.h"
#include <iostream>
#include <sstream>
using namespace std;
......@@ -452,5 +453,12 @@ Value JsonPP::objectFromString(std::string jsonString)
return newValue;
}
std::string JsonPP::stringFromObject ( Object& jsonObject )
{
auto jss = std::stringstream {};
jss << jsonObject;
return jss.str();
}
}
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment