Main class used to convert QVariant objects to JSON data. More...
#include <serializer.h>
Public Member Functions | |
void | serialize (const QVariant &variant, QIODevice *out, bool *ok) |
QByteArray | serialize (const QVariant &variant) |
QByteArray | serialize (const QVariant &variant, bool *ok) |
void | allowSpecialNumbers (bool allow) |
bool | specialNumbersAllowed () const |
void | setIndentMode (IndentMode mode=QJson::IndentNone) |
void | setDoublePrecision (int precision) |
IndentMode | indentMode () const |
QString | errorMessage () const |
Main class used to convert QVariant objects to JSON data.
QVariant objects are converted to a string containing the JSON data.
Usage:
The output will be:
It's possible to tune the indentation level of the resulting string.
Definition at line 110 of file serializer.h.
void QJson::Serializer::allowSpecialNumbers | ( | bool | allow | ) |
Allow or disallow writing of NaN and/or Infinity (as an extension to QJson)
Definition at line 390 of file serializer.cpp.
QString QJson::Serializer::errorMessage | ( | ) | const |
Returns the error message
Definition at line 410 of file serializer.cpp.
IndentMode QJson::Serializer::indentMode | ( | ) | const |
Returns one of the indentation modes defined in QJson::IndentMode
Definition at line 406 of file serializer.cpp.
void Serializer::serialize | ( | const QVariant & | variant, |
QIODevice * | out, | ||
bool * | ok | ||
) |
This method generates a textual JSON representation and outputs it to the passed in I/O Device.
variant | The JSON document in its in-memory representation as generated by the parser. |
out | Input output device |
ok | if a conversion error occurs, *ok is set to false; otherwise *ok is set to true |
Definition at line 342 of file serializer.cpp.
Referenced by serialize().
QByteArray Serializer::serialize | ( | const QVariant & | variant | ) |
This is a method provided for convenience. It turns the passed in in-memory representation of the JSON document into a textual one, which is returned. If the returned string is empty, the document was empty. If it was null, there was a parsing error.
variant | The JSON document in its in-memory representation as generated by the parser. |
Definition at line 369 of file serializer.cpp.
References serialize().
QByteArray Serializer::serialize | ( | const QVariant & | variant, |
bool * | ok | ||
) |
This is a method provided for convenience. It turns the passed in in-memory representation of the JSON document into a textual one, which is returned. If the returned string is empty, the document was empty. If it was null, there was a parsing error.
variant | The JSON document in its in-memory representation as generated by the parser. |
ok | if a conversion error occurs, *ok is set to false; otherwise *ok is set to true |
Definition at line 376 of file serializer.cpp.
void QJson::Serializer::setDoublePrecision | ( | int | precision | ) |
set double precision used while converting Double
Definition at line 402 of file serializer.cpp.
void QJson::Serializer::setIndentMode | ( | IndentMode | mode = QJson::IndentNone | ) |
set output indentation mode as defined in QJson::IndentMode
Definition at line 398 of file serializer.cpp.
bool QJson::Serializer::specialNumbersAllowed | ( | ) | const |
Is Nan and/or Infinity allowed?
Definition at line 394 of file serializer.cpp.
hosts this site. |
Send comments to: QJson Developers |