A Json parser. More...
#include <jsonparser.hpp>
Public Member Functions | |
JsonParser () | |
QVariantMap | parse (const QString &jsonData, bool *ok=0) |
Parsing method. | |
QString | lastError () const |
Last error retrieving method. | |
void | clearLastError () |
Method to clear the last error. | |
Protected Member Functions | |
QVariantMap | parseObject (QString object, bool *ok) |
Object parsing method. | |
QVariantMap | parsePair (const QString &value, bool *ok) |
Pair parsing method. | |
QVariant | parseValue (QString valeur, bool *ok) |
Value parsing method. | |
QVariantList | parseArray (QString array, bool *ok) |
Array parsing method. | |
QVariant | parseNumber (const QString &value, bool *ok) |
Number parsing method. | |
Static Protected Member Functions | |
static QStringList | split (QString string, QChar separator) |
String splitting method. | |
Protected Attributes | |
QString | m_lastError |
String descripting the last error that occured. | |
Static Protected Attributes | |
static QList< QChar > | caractereEvitementDebut |
opening characters used to plit the Json strings. | |
static QList< QChar > | caractereEvitementFin |
closing characters used to plit the Json strings. |
A Json parser.
This parser is used to parse a String containing Json description of an object, and create a QVariantMap corresponding to the Json string. The main method to use is the parse() methode, which take the Json string and return the corresponding QVariantMap.
Definition at line 45 of file jsonparser.hpp.
QExtend::JsonParser::JsonParser | ( | ) |
void QExtend::JsonParser::clearLastError | ( | ) |
Method to clear the last error.
This method clears the last error string
QString QExtend::JsonParser::lastError | ( | ) | const |
Last error retrieving method.
Return the string describing the last error that occured.
QVariantMap QExtend::JsonParser::parse | ( | const QString & | jsonData, | |
bool * | ok = 0 | |||
) |
Parsing method.
Main method of the JsonParser class, it converts a Json string into a QVariantMap. the boolean is used to know if an error occured while parsing.
QVariantList QExtend::JsonParser::parseArray | ( | QString | array, | |
bool * | ok | |||
) | [protected] |
Array parsing method.
This method is used to parse an array. In Json format, an array is a collection of values separated by commas, starts with `[` and ends with `]`.
QVariant QExtend::JsonParser::parseNumber | ( | const QString & | value, | |
bool * | ok | |||
) | [protected] |
Number parsing method.
This method is used to parse an number.
QVariantMap QExtend::JsonParser::parseObject | ( | QString | object, | |
bool * | ok | |||
) | [protected] |
Object parsing method.
This method is used to parse an object. In Json format, an object starts with `{` and ends with `}`, and is composed of a collection of pairs separated by commas.
QVariantMap QExtend::JsonParser::parsePair | ( | const QString & | value, | |
bool * | ok | |||
) | [protected] |
Pair parsing method.
This method is used to parse a pair. A pair describes a membre of the object. In Json format, a pair is composed of a string, which is the name of the membre, and after a colon, the value of the membre.
QVariant QExtend::JsonParser::parseValue | ( | QString | valeur, | |
bool * | ok | |||
) | [protected] |
Value parsing method.
This method is used to parse a value. In Json format, a value can in fact be of several types, it can either be a string, a number, a boolean, an object, an array or it can be null.
static QStringList QExtend::JsonParser::split | ( | QString | string, | |
QChar | separator | |||
) | [static, protected] |
String splitting method.
This method is used to split a string into various basic components that can be parsed by the specialized methodes of this class.
QList<QChar> QExtend::JsonParser::caractereEvitementDebut [static, protected] |
opening characters used to plit the Json strings.
Definition at line 52 of file jsonparser.hpp.
QList<QChar> QExtend::JsonParser::caractereEvitementFin [static, protected] |
closing characters used to plit the Json strings.
Definition at line 55 of file jsonparser.hpp.
QString QExtend::JsonParser::m_lastError [protected] |
String descripting the last error that occured.
Definition at line 49 of file jsonparser.hpp.
© 2000-2024 - www.developpez.com