1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-04 21:27:58 +02:00

Add JSON serialization wrapper

This commit is contained in:
Uwe L. Korn
2014-04-13 21:20:06 +01:00
parent ddf00b5991
commit 59b10b725c
2 changed files with 15 additions and 0 deletions

View File

@@ -861,6 +861,20 @@ parseJson( const QByteArray& jsonData, bool* ok )
} }
QByteArray
toJson( const QVariant &variant, bool* ok )
{
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
QJsonDocument doc = QJsonDocument::fromVariant( variant );
*ok = true;
return doc.toJson();
#else
QJson::Serializer serializer;
return serializer.serialize( variant, ok );
#endif
}
void void
urlAddQueryItem( QUrl& url, const QString& key, const QString& value ) urlAddQueryItem( QUrl& url, const QString& key, const QString& value )
{ {

View File

@@ -209,6 +209,7 @@ namespace TomahawkUtils
/* QJson */ /* QJson */
DLLEXPORT QVariant parseJson( const QByteArray& jsonData, bool* ok = 0 ); DLLEXPORT QVariant parseJson( const QByteArray& jsonData, bool* ok = 0 );
DLLEXPORT QByteArray toJson( const QVariant &variant, bool* ok = 0 );
/* QUrl */ /* QUrl */
DLLEXPORT void urlAddQueryItem( QUrl& url, const QString& key, const QString& value ); DLLEXPORT void urlAddQueryItem( QUrl& url, const QString& key, const QString& value );