Poco::JSON

class Query

Library: JSON
Package: JSON
Header: Poco/JSON/Query.h

Description

Class that can be used to search for a value in a JSON object or array.

Member Summary

Member Functions: find, findArray, findObject, findValue

Constructors

Query

Query(
    const Dynamic::Var & source
);

Constructor. Pass the start object/array.

Destructor

~Query virtual

virtual ~Query();

Destructor

Member Functions

find

Dynamic::Var find(
    const std::string & path
) const;

Searches a value For example: "person.children[0].name" will return the the name of the first child. When the value can't be found an empty value is returned.

findArray

Array::Ptr findArray(
    const std::string & path
) const;

Search for an array. When the array can't be found, an empty SharedPtr is returned.

findObject

Object::Ptr findObject(
    const std::string & path
) const;

Search for an object. When the object can't be found, an empty SharedPtr is returned.

findValue inline

template < typename T > T findValue(
    const std::string & path,
    const T & def
) const;

Searches for a value will convert it to the given type. When the value can't be found or has an invalid type the default value will be returned.

findValue inline

std::string findValue(
    const char * path,
    const char * def
) const;

Searches for a value will convert it to the given type. When the value can't be found or has an invalid type the default value will be returned.