1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QT3DCORE_QLOADGLTF_P_H
5#define QT3DCORE_QLOADGLTF_P_H
6
7#include <QtCore/qcborarray.h>
8#include <QtCore/qcbormap.h>
9#include <QtCore/qcborvalue.h>
10#include <QtCore/qjsonarray.h>
11#include <QtCore/qjsondocument.h>
12#include <QtCore/qjsonobject.h>
13#include <private/qglobal_p.h>
14
15//
16// W A R N I N G
17// -------------
18//
19// This file is not part of the Qt API. It exists for the convenience
20// of other Qt classes. This header file may change from version to
21// version without notice, or even be removed.
22//
23// We mean it.
24//
25
26inline QJsonDocument qLoadGLTF(const QByteArray &gltfData)
27{
28 {
29 const QCborValue cbor = QCborValue::fromCbor(ba: gltfData);
30 if (cbor.isMap())
31 return QJsonDocument(cbor.toMap().toJsonObject());
32 if (cbor.isArray())
33 return QJsonDocument(cbor.toArray().toJsonArray());
34 }
35 return QJsonDocument::fromJson(json: gltfData);
36}
37
38#endif // QT3DCORE_QLOADGLTF_P_H
39

source code of qt3d/src/core/resources/qloadgltf_p.h