diff options
author | Sefa Eyeoglu <contact@scrumplex.net> | 2022-07-10 19:21:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-10 19:21:01 +0200 |
commit | cd948dceaed4625e7a876f680d3dc028e6cfe6de (patch) | |
tree | 9a1da832444744f126477e6925dcd78172989bed /launcher/Json.cpp | |
parent | c1bcbf8c63ef4543fdf0d5529089721d2b4a01dd (diff) | |
parent | eb33a87ff5ba01d05f6a96d4d06a0d00fdd85647 (diff) | |
download | PrismLauncher-cd948dceaed4625e7a876f680d3dc028e6cfe6de.tar.gz PrismLauncher-cd948dceaed4625e7a876f680d3dc028e6cfe6de.tar.bz2 PrismLauncher-cd948dceaed4625e7a876f680d3dc028e6cfe6de.zip |
Merge pull request #575 from Scrumplex/qt6
Diffstat (limited to 'launcher/Json.cpp')
-rw-r--r-- | launcher/Json.cpp | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/launcher/Json.cpp b/launcher/Json.cpp index 37ada1aa..06b3d3bd 100644 --- a/launcher/Json.cpp +++ b/launcher/Json.cpp @@ -1,4 +1,37 @@ -// Licensed under the Apache-2.0 license. See README.md for details. +// SPDX-License-Identifier: GPL-3.0-only +/* + * PolyMC - Minecraft Launcher + * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright 2013-2021 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #include "Json.h" @@ -22,14 +55,6 @@ void write(const QJsonArray &array, const QString &filename) write(QJsonDocument(array), filename); } -QByteArray toBinary(const QJsonObject &obj) -{ - return QJsonDocument(obj).toBinaryData(); -} -QByteArray toBinary(const QJsonArray &array) -{ - return QJsonDocument(array).toBinaryData(); -} QByteArray toText(const QJsonObject &obj) { return QJsonDocument(obj).toJson(QJsonDocument::Compact); @@ -48,12 +73,8 @@ QJsonDocument requireDocument(const QByteArray &data, const QString &what) { if (isBinaryJson(data)) { - QJsonDocument doc = QJsonDocument::fromBinaryData(data); - if (doc.isNull()) - { - throw JsonException(what + ": Invalid JSON (binary JSON detected)"); - } - return doc; + // FIXME: Is this needed? + throw JsonException(what + ": Invalid JSON. Binary JSON unsupported"); } else { |