Added contructor with Json::Value and operator Json::Value() to Entity

This commit is contained in:
tastytea 2019-03-11 20:41:52 +01:00
parent cc43f133a4
commit 1f36568b20
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 21 additions and 0 deletions

View File

@ -333,6 +333,15 @@ public:
*/
explicit Entity(const string &json);
/*!
* @brief Constructs an Entity object from a JSON object.
*
* @param object JSON object
*
* @since 0.100.0
*/
explicit Entity(const Json::Value &object);
/*!
* @brief Constructs an empty Entity object.
*
@ -347,6 +356,8 @@ public:
*/
virtual ~Entity();
operator const Json::Value() const;
/*!
* @brief Replaces the Entity with a new one from a JSON string.
*

View File

@ -33,6 +33,11 @@ Easy::Entity::Entity(const string &json)
from_string(json);
}
Easy::Entity::Entity(const Json::Value &object)
: _tree(object)
,_was_set(false)
{}
Easy::Entity::Entity()
: _was_set(false)
{}
@ -40,6 +45,11 @@ Easy::Entity::Entity()
Easy::Entity::~Entity()
{}
Easy::Entity::operator const Json::Value() const
{
return to_object();
}
void Easy::Entity::from_string(const string &json)
{
std::stringstream ss(json);