QJson home page
src
serializer.h
1
/* This file is part of qjson
2
*
3
* Copyright (C) 2009 Till Adam <adam@kde.org>
4
*
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License version 2.1, as published by the Free Software Foundation.
8
*
9
*
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
14
*
15
* You should have received a copy of the GNU Lesser General Public License
16
* along with this library; see the file COPYING.LIB. If not, write to
17
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
* Boston, MA 02110-1301, USA.
19
*/
20
21
#ifndef QJSON_SERIALIZER_H
22
#define QJSON_SERIALIZER_H
23
24
#include "qjson_export.h"
25
26
QT_BEGIN_NAMESPACE
27
class
QIODevice;
28
class
QString;
29
class
QVariant;
30
QT_END_NAMESPACE
31
32
namespace
QJson
{
103
enum
IndentMode
{
104
IndentNone,
105
IndentCompact,
106
IndentMinimum,
107
IndentMedium,
108
IndentFull
109
};
151
class
QJSON_EXPORT
Serializer
{
152
public
:
153
Serializer
();
154
~
Serializer
();
155
164
void
serialize(
const
QVariant& variant, QIODevice* out,
bool
* ok);
165
177
QByteArray serialize(
const
QVariant& variant);
178
189
QByteArray serialize(
const
QVariant& variant,
bool
*ok);
190
194
void
allowSpecialNumbers(
bool
allow);
195
199
bool
specialNumbersAllowed()
const
;
200
204
void
setIndentMode(
IndentMode
mode = QJson::IndentNone);
205
206
211
void
setDoublePrecision(
int
precision);
212
216
IndentMode
indentMode()
const
;
217
221
QString errorMessage()
const
;
222
223
private
:
224
Q_DISABLE_COPY(
Serializer
)
225
class
SerializerPrivate;
226
SerializerPrivate*
const
d;
227
};
228
}
229
230
#endif // QJSON_SERIALIZER_H
QJson
Definition:
json_parser.hh:60
QJson::Serializer
Main class used to convert QVariant objects to JSON data.
Definition:
serializer.h:151
QJson::IndentMode
IndentMode
How the indentation should work.
Definition:
serializer.h:103
hosts this site.
Send comments to:
QJson Developers