1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-19 15:29:42 +01: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
urlAddQueryItem( QUrl& url, const QString& key, const QString& value )
{

View File

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