EvolvingObjects
|
Parser from a JSON source. More...
#include <Parser.h>
Static Public Member Functions | |
static eoserial::Object * | parse (const std::string &str) |
Parses the given string and returns the JSON object read. | |
Static Protected Member Functions | |
static eoserial::Entity * | parseRight (const std::string &str, size_t &pos) |
Parses the right part of a JSON object as a string. | |
static void | parseLeft (const std::string &str, size_t &pos, eoserial::Object *json) |
Parses the left value of a key-value pair, which is the key. | |
static eoserial::String * | parseJsonString (const std::string &str, size_t &pos) |
Retrieves a string in a JSON content. |
Parser from a JSON source.
This parser does just retrieve values and does NOT check the structure of the input. This implies that if the input is not correct, the result is undefined and can result to a failure on execution.
Entity * eoserial::Parser::parseRight | ( | const std::string & | str, |
size_t & | pos | ||
) | [static, protected] |
Parses the right part of a JSON object as a string.
The right part of an object can be a string (for instance : "key":"value"), a JSON array (for instance: "key":["1"]) or another JSON object (for instance: "key":{"another_key":"value"}).
The right parts are found after keys (which are parsed by parseLeft) and in arrays.
str | The string we're parsing. |
pos | The index of the current position in the string. |
Definition at line 117 of file Parser.cpp.
References eoserial::Array::push_back().
void eoserial::Parser::parseLeft | ( | const std::string & | str, |
size_t & | pos, | ||
eoserial::Object * | json | ||
) | [static, protected] |
Parses the left value of a key-value pair, which is the key.
str | The string we're parsing. |
pos | The index of the current position in the string. |
json | The current JSON object for which we're adding a key-value pair. |
Definition at line 162 of file Parser.cpp.
String * eoserial::Parser::parseJsonString | ( | const std::string & | str, |
size_t & | pos | ||
) | [static, protected] |
Retrieves a string in a JSON content.
str | The string we're parsing. |
pos | The index of the current position of parsing, which will be updated. |
Definition at line 106 of file Parser.cpp.