QJson home page
serializerrunnable.cpp
1#include "serializerrunnable.h"
2
3/* This file is part of qjson
4 *
5 * Copyright (C) 2009 Flavio Castelli <flavio@castelli.name>
6 * 2009 Frank Osterfeld <osterfeld@kde.org>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software Foundation.
11 *
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 */
23
24#include "parserrunnable.h"
25#include "serializer.h"
26
27#include <QtCore/QDebug>
28#include <QtCore/QVariant>
29
30using namespace QJson;
31
32class SerializerRunnable::Private
33{
34public:
35 QVariant json;
36};
37
38SerializerRunnable::SerializerRunnable(QObject* parent)
39 : QObject(parent),
40 QRunnable(),
41 d(new Private)
42{
43 qRegisterMetaType<QVariant>("QVariant");
44}
45
46SerializerRunnable::~SerializerRunnable()
47{
48 delete d;
49}
50
51void SerializerRunnable::setJsonObject( const QVariant& json )
52{
53 d->json = json;
54}
55
56void SerializerRunnable::run()
57{
58 Serializer serializer;
59 bool ok;
60 const QByteArray serialized = serializer.serialize( d->json, &ok);
61 emit parsingFinished( serialized, ok, serializer.errorMessage() );
62}
void setJsonObject(const QVariant &json)
void parsingFinished(const QByteArray &serialized, bool ok, const QString &error_msg)
Main class used to convert QVariant objects to JSON data.
Definition: serializer.h:151
void serialize(const QVariant &variant, QIODevice *out, bool *ok)
Definition: serializer.cpp:398
QString errorMessage() const
Definition: serializer.cpp:466

SourceForge Logo hosts this site. Send comments to:
QJson Developers