TTKMusicPlayer
4.1.3.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
|
Main class used to convert QVariant objects to JSON data. More...
#include <serializer.h>
Classes | |
class | SerializerPrivate |
Main class used to convert QVariant objects to JSON data private. More... | |
Public Member Functions | |
Serializer () | |
void | 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. More... | |
QByteArray | serialize (const QVariant &variant, bool *ok) |
This is a method provided for convenience. More... | |
void | allowSpecialNumbers (bool allow) |
Allow or disallow writing of NaN and/or Infinity (as an extension to QJson) More... | |
bool | specialNumbersAllowed () const |
Is Nan and/or Infinity allowed? More... | |
void | setIndentMode (IndentMode mode=QJson::IndentNone) |
set output indentation mode as defined in QJson::IndentMode More... | |
void | setDoublePrecision (int precision) |
set double precision used while converting Double More... | |
IndentMode | indentMode () const |
Returns one of the indentation modes defined in QJson::IndentMode. More... | |
QString | errorMessage () const |
Returns the error message. More... | |
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 151 of file serializer.h.
Serializer::Serializer | ( | ) |
Definition at line 415 of file serializer.cpp.
References TTK_INIT_PRIVATE.
void QJson::Serializer::allowSpecialNumbers | ( | bool | allow | ) |
Allow or disallow writing of NaN and/or Infinity (as an extension to QJson)
Definition at line 464 of file serializer.cpp.
References TTK_D.
QString QJson::Serializer::errorMessage | ( | ) | const |
Returns the error message.
Definition at line 494 of file serializer.cpp.
References TTK_D.
Referenced by QJson::SerializerRunnable::run().
IndentMode QJson::Serializer::indentMode | ( | ) | const |
Returns one of the indentation modes defined in QJson::IndentMode.
Definition at line 488 of file serializer.cpp.
References TTK_D.
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 420 of file serializer.cpp.
References TTK_D.
Referenced by QJson::SerializerRunnable::run(), and MusicJSPFConfigManager::writeBuffer().
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 449 of file serializer.cpp.
References TTK_D.
void QJson::Serializer::setDoublePrecision | ( | int | precision | ) |
set double precision used while converting Double
Definition at line 482 of file serializer.cpp.
References TTK_D.
void QJson::Serializer::setIndentMode | ( | IndentMode | mode = QJson::IndentNone | ) |
set output indentation mode as defined in QJson::IndentMode
Definition at line 476 of file serializer.cpp.
References TTK_D.
bool QJson::Serializer::specialNumbersAllowed | ( | ) | const |