Added test for malformed JSON.
This commit is contained in:
parent
f84a272f53
commit
5408f6f235
|
@ -54,8 +54,15 @@ Easy::Entity::operator const Json::Value() const
|
||||||
|
|
||||||
void Easy::Entity::from_string(const string &json)
|
void Easy::Entity::from_string(const string &json)
|
||||||
{
|
{
|
||||||
std::stringstream ss(json);
|
if (json.find('{') != std::string::npos)
|
||||||
ss >> _tree;
|
{
|
||||||
|
std::stringstream ss(json);
|
||||||
|
ss >> _tree;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_tree.clear();
|
||||||
|
}
|
||||||
|
|
||||||
// If the JSON is a single object encapsulated in an array,
|
// If the JSON is a single object encapsulated in an array,
|
||||||
// transform it into an object. If the JSON string is [], transform to null
|
// transform it into an object. If the JSON string is [], transform to null
|
||||||
|
|
Reference in New Issue