According to this you should be able to convert any QVariant to QJSonObject
Now your question become : how to transform your Foo class to QVariant ?
I suggest you to add toQVariant and fromQVariant methods to Foo class to encapsulate this behavior ; the most convenient QVariant class is actually QVariantMap that you can use like this to serialize your Foo object
QVariant toVariant( Foo song ) {
QVariantMap map;
map.insert("album", wstring2Utf8(song.album()));
map.insert("artist", wstring2Utf8(song.artist()));
map.insert("duration", song.duration());
map.insert("fingerprint", wstring2Utf8(song.fingerprint()));
map.insert("genre", wstring2Utf8(song.genre()));
map.insert("title", wstring2Utf8(song.title()));
map.insert("year", song.year());
return map;
}