![]() |
Open Lighting Architecture
0.9.1
|
A JSON pointer (RFC 6901) refers to a possible element in a JSON data structure.
The element referenced by the pointer may or may not exist.
Given the JSON:
{ "foo": { "bar": 1, "baz": true }, "bat": [0, 1, 2] }
The JSON pointers for each element are:
Classes | |
class | Iterator |
An iterator for traversing a JsonPointer. More... |
Public Member Functions | |
JsonPointer (const JsonPointer &other) | |
JsonPointer (const std::string &path) | |
Construct a new JsonPointer from a string representing the path. | |
bool | operator== (const JsonPointer &other) const |
Equality operator. | |
bool | IsValid () const |
Returns true if this pointer is valid. | |
Iterator | begin () const |
Return an iterator pointing to the first token in the JsonPointer. | |
unsigned int | TokenCount () const |
The number of tokens in the Json Pointer. | |
std::string | TokenAt (unsigned int i) const |
Return the token at the specifed index. | |
void | Push (const std::string &token) |
Append a token to the pointer path. | |
void | Pop () |
Pop the last token from the pointer. | |
std::string | ToString () const |
Returns the string representation of the pointer. | |
bool | IsPrefixOf (const JsonPointer &other) const |
Check if this pointer is a prefix of another. |
|
explicit |
Construct a new JsonPointer from a string representing the path.
path | A Json Pointer path. The path should either be empty, or start with a /. |
bool ola::web::JsonPointer::IsPrefixOf | ( | const JsonPointer & | other | ) | const |
Check if this pointer is a prefix of another.
other | the JsonPointer to compare to. |
|
inline |
Returns true if this pointer is valid.
Invalid pointers are ones that don't start with a /. If the pointer is invalid, the result of all other methods is undefined.
void ola::web::JsonPointer::Push | ( | const std::string & | token | ) |
Append a token to the pointer path.
token | The un-escaped token to add to this JsonPointer. |
|
inline |
Return the token at the specifed index.
i | the index of the token to return. |
|
inline |
The number of tokens in the Json Pointer.
A valid pointer has at least one token (""). The number of tokens is the number of / plus one.