This repository has been archived on 2025-12-24. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
yachat/third-party/JsonQt/lib/VariantToJson.h

41 lines
953 B
C
Raw Permalink Normal View History

2025-12-25 01:37:49 +05:00
#ifndef _JSONQT_VARIANT_TO_JSON_H
#define _JSONQT_VARIANT_TO_JSON_H
#include "JsonQtExport.h"
#include <QString>
#include <QStringList>
#include <QVariant>
namespace JsonQt
{
/** Class for converting QVariants into JSON structures.
*
* The following variant types are supported:
* - QVariant::Bool
* - QVariant::String
* - QVariant::Double
* - QVariant::Int
* - QVariant::LongLong
* - QVariant::UInt
* - QVariant::ULongLong
* - QVariant::Invalid
* - QVariant::List // JSON array
* - QVariant::Map // JSON object
*
* @author Fred Emmott <mail@fredemmott.co.uk>
*/
class JSONQT_EXPORT VariantToJson
{
public:
/// Parse a QVariant into JSON.
static QString parse(const QVariantMap& data);
private:
static QString parseElement(const QVariant& element);
static QString parseList(const QVariantList& list);
static QString parseStringList(const QStringList& list);
};
}
#endif