LeechCraft
0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
parsejson.h
Go to the documentation of this file.
1
/**********************************************************************
2
* LeechCraft - modular cross-platform feature rich internet client.
3
* Copyright (C) 2006-2014 Georg Rudoy
4
*
5
* Distributed under the Boost Software License, Version 1.0.
6
* (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7
**********************************************************************/
8
9
#pragma once
10
11
#include <QByteArray>
12
#include <QVariant>
13
#include <QIODevice>
14
#include <QtDebug>
15
#include <QJsonDocument>
16
17
namespace
LC
18
{
19
namespace
Util
20
{
31
inline
QVariant
ParseJson
(
const
QByteArray& bytes,
const
char
*context)
32
{
33
QJsonParseError error;
34
const
auto
& result = QJsonDocument::fromJson (bytes, &error).toVariant ();
35
if
(error.error != QJsonParseError::NoError)
36
{
37
qWarning () << context
38
<<
"cannot parse"
39
<< error.errorString ();
40
return
{};
41
}
42
return
result;
43
}
44
56
inline
QVariant
ParseJson
(QIODevice *device,
const
char
*context)
57
{
58
return
ParseJson
(device->readAll (), context);
59
}
60
}
61
}
LC::Util
Definition
icoreproxy.h:34
LC::Util::ParseJson
QVariant ParseJson(const QByteArray &bytes, const char *context)
Parses JSON content in the given bytearray.
Definition
parsejson.h:31
LC
Definition
constants.h:15
src
util
sll
parsejson.h
Generated by
1.13.1