24 #include "json_parser.hh"
27 #include <QtCore/QBuffer>
28 #include <QtCore/QStringList>
29 #include <QtCore/QTextStream>
31 using namespace QJson;
35 m_specialNumbersAllowed(false)
75 if (!io->open(QIODevice::ReadOnly)) {
78 qCritical (
"Error opening device");
83 if (!io->isReadable()) {
86 qCritical (
"Device is not readable");
94 d->setError(QLatin1String(
"No data"), 0);
100 d->m_scanner->allowSpecialNumbers(d->m_specialNumbersAllowed);
101 yy::json_parser parser(d);
117 buffer.open(QIODevice::ReadWrite | QIODevice::Text);
118 buffer.write(jsonString);
120 return parse (&buffer, ok);
126 return d->m_errorMsg;
132 return d->m_errorLine;
138 d->m_specialNumbersAllowed = allowSpecialNumbers;
144 return d->m_specialNumbersAllowed;
QString errorString() const
This method returns the error message.
void setError(const QString &errorMsg, int line)
bool specialNumbersAllowed() const
QVariant parse(QIODevice *io, bool *ok=0)
Read JSON string from the I/O Device and converts it to a QVariant object.
void allowSpecialNumbers(bool allowSpecialNumbers)
Sets whether special numbers (Infinity, -Infinity, NaN) are allowed as an extension to the standard...
int errorLine() const
This method returns line number where the error occurred.
#define TTK_INIT_PRIVATE(Class)
Main class used to convert JSON data to QVariant objects.