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:
parent
ddf00b5991
commit
59b10b725c
@ -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 )
|
||||
{
|
||||
|
@ -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 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user