//
// Query.cpp
//
// $Id$
//
// Library: JSON
// Package: JSON
// Module: Query
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/JSON/Query.h"
#include "Poco/StringTokenizer.h"
#include "Poco/RegularExpression.h"
#include "Poco/NumberParser.h"
#include
using Poco::Dynamic::Var;
namespace Poco {
namespace JSON {
Query::Query(const Var& source): _source(source)
{
if (!source.isEmpty() &&
source.type() != typeid(Object) &&
source.type() != typeid(Object::Ptr) &&
source.type() != typeid(Array) &&
source.type() != typeid(Array::Ptr))
throw InvalidArgumentException("Only JSON Object, Array or pointers thereof allowed.");
}
Query::~Query()
{
}
Object::Ptr Query::findObject(const std::string& path) const
{
Var result = find(path);
if (result.type() == typeid(Object::Ptr))
return result.extract<:ptr>();
else if (result.type() == typeid(Object))
return new Object(result.extract