QJson - a Qt based library for mapping JSON data to QVariant objects

QJson home page

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

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
30 using namespace QJson;
31
32 class SerializerRunnable::Private
33 {
34 public:
35 QVariant json;
36 };
37
38 SerializerRunnable::SerializerRunnable(QObject* parent)
39 : QObject(parent),
40 QRunnable(),
41 d(new Private)
42 {
43 qRegisterMetaType<QVariant>("QVariant");
44 }
45
46 SerializerRunnable::~SerializerRunnable()
47 {
48 delete d;
49 }
50
51 void SerializerRunnable::setJsonObject( const QVariant& json )
52 {
53 d->json = json;
54 }
55
56 void 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 }
QJson::SerializerRunnable::parsingFinished
void parsingFinished(const QByteArray &serialized, bool ok, const QString &error_msg)
Definition: moc_serializerrunnable.cxx:98
QJson::Serializer
Main class used to convert QVariant objects to JSON data.
Definition: serializer.h:110
QJson::SerializerRunnable::setJsonObject
void setJsonObject(const QVariant &json)
Definition: serializerrunnable.cpp:51
QJson::Serializer::serialize
void serialize(const QVariant &variant, QIODevice *out, bool *ok)
Definition: serializer.cpp:342
QJson
Definition: json_parser.hh:66
QJson::Serializer::errorMessage
QString errorMessage() const
Definition: serializer.cpp:410

| hosts this site. |  | Send comments to: QJson Developers