mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 11:06:50 +01:00
back-port JSON and accompanying Foundation portions (JSONString, Dynamic::Var etc)
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "Poco/JSON/ParseHandler.h"
|
||||
#include "Poco/JSON/Object.h"
|
||||
#include "Poco/JSON/JSONException.h"
|
||||
|
||||
|
||||
using Poco::Dynamic::Var;
|
||||
@@ -47,7 +48,6 @@ void ParseHandler::reset()
|
||||
void ParseHandler::startObject()
|
||||
{
|
||||
Object::Ptr newObj = new Object(_preserveObjectOrder);
|
||||
|
||||
if (_stack.empty()) // The first object
|
||||
{
|
||||
_result = newObj;
|
||||
@@ -124,18 +124,25 @@ void ParseHandler::key(const std::string& k)
|
||||
|
||||
void ParseHandler::setValue(const Var& value)
|
||||
{
|
||||
Var parent = _stack.top();
|
||||
if (_stack.size())
|
||||
{
|
||||
Var parent = _stack.top();
|
||||
|
||||
if (parent.type() == typeid(Array::Ptr))
|
||||
{
|
||||
Array::Ptr arr = parent.extract<Array::Ptr>();
|
||||
arr->add(value);
|
||||
if (parent.type() == typeid(Array::Ptr))
|
||||
{
|
||||
Array::Ptr arr = parent.extract<Array::Ptr>();
|
||||
arr->add(value);
|
||||
}
|
||||
else if (parent.type() == typeid(Object::Ptr))
|
||||
{
|
||||
Object::Ptr obj = parent.extract<Object::Ptr>();
|
||||
obj->set(_key, value);
|
||||
_key.clear();
|
||||
}
|
||||
}
|
||||
else if (parent.type() == typeid(Object::Ptr))
|
||||
else
|
||||
{
|
||||
Object::Ptr obj = parent.extract<Object::Ptr>();
|
||||
obj->set(_key, value);
|
||||
_key.clear();
|
||||
throw JSONException("Attempt to set value on an empty stack");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user