|
crawlserv++
[under development]
Application for crawling and analyzing textual content of websites.
|
Implements an extended JSONPointer query using the rapidJSON library.
More...
#include <JsonPointer.hpp>
Classes | |
| class | Exception |
| Class for JSONPointer exceptions. More... | |
Construction | |
| JsonPointer (const std::string &pointerString, bool textOnlyQuery) | |
| Constructor setting a JSONPointer string and whether the result should be text-only. More... | |
Getters | |
| bool | getBool (const rapidjson::Document &doc) const |
| Gets a boolean result from performing the query on a parsed JSON document. More... | |
| void | getFirst (const rapidjson::Document &doc, std::string &resultTo) const |
| Gets the first match from performing the query on a parsed JSON document. More... | |
| void | getAll (const rapidjson::Document &doc, std::vector< std::string > &resultTo) const |
| Gets all matches from performing the query on a parsed JSON document. More... | |
| void | getSubSets (const rapidjson::Document &doc, std::vector< rapidjson::Document > &resultTo) const |
| Gets all matching subsets from performing the query on a parsed JSON document. More... | |
Implements an extended JSONPointer query using the rapidJSON library.
For more information about the rapidJSON library, see its GitHub repository.
Different from the JSONPointer standard (and the library), multiple results are possible by using $$ as a placeholder for 0..n, where n is the number of matches minus 1.
|
inline |
Constructor setting a JSONPointer string and whether the result should be text-only.
| pointerString | Const reference to a string containing the JSONPointer expression. Will be trimmed before use. |
| textOnlyQuery | Set whether the query should result in raw text only. In case of an array, the full array string will be returned by getFirst when the query is text-only. The same is true for getAll if there is only one match. |
| JsonPointer::Exception | if the given string is empty after trimming, or it contains an invalid JSONPointer query. |
References crawlservpp::Helper::Strings::replaceAll(), and crawlservpp::Helper::Strings::trim().
|
inline |
Gets all matches from performing the query on a parsed JSON document.
| doc | Const reference to a JSON document parsed by the rapidJSON library. |
| resultTo | Reference to a vector to which the results will be written. The vector will be cleared even if an error occurs during execution of the query. |
| JsonPointer::Exception | if parsing errors occured in the given JSON document or no valid JSONPointer query has been set. |
References crawlservpp::Helper::Strings::replaceAll(), and crawlservpp::Helper::Json::stringify().
Referenced by crawlservpp::Main::Server::tick().
|
inline |
Gets a boolean result from performing the query on a parsed JSON document.
| doc | Const reference to a JSON document parsed by the rapidJSON library. |
| JsonPointer::Exception | if parsing errors occured in the given JSON document or no valid JSONPointer query has been set. |
Referenced by crawlservpp::Main::Server::tick().
|
inline |
Gets the first match from performing the query on a parsed JSON document.
| doc | Const reference to a JSON document parsed by the rapidJSON library. |
| resultTo | Reference to a string to which the result will be written. The string will be cleared even if an error occurs during execution of the query. |
| JsonPointer::Exception | if parsing errors occured in the given JSON document or no valid JSONPointer query has been set. |
References crawlservpp::Helper::Json::stringify().
Referenced by crawlservpp::Main::Server::tick().
|
inline |
Gets all matching subsets from performing the query on a parsed JSON document.
The subsets will be saved as JSON documents as defined by the rapidJSON library.
| doc | Const reference to a JSON document parsed by the jsoncons library. |
| resultTo | Reference to a vector to which the results will be written. The vector will be cleared even if an error occurs during execution of the query. |
| JsonPointer::Exception | if parsing errors occured in the given JSON document or no valid JSONPointer query has been set. |
References crawlservpp::Helper::Strings::replaceAll().
Referenced by crawlservpp::Main::Server::tick().