KTextAddons

languagetoolparser.cpp
1/*
2 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "languagetoolparser.h"
8using namespace Qt::Literals::StringLiterals;
9
10#include "languagetoolgrammarerror.h"
11
12#include <QJsonArray>
13
14using namespace TextGrammarCheck;
15
16LanguageToolParser::LanguageToolParser() = default;
17
18LanguageToolParser::~LanguageToolParser() = default;
19
20QVector<GrammarError> LanguageToolParser::parseResult(const QJsonObject &obj) const
21{
23 const QJsonArray array = obj.value("matches"_L1).toArray();
24 for (const QJsonValue &current : array) {
25 // qDebug() << " current " << current;
26 if (current.type() == QJsonValue::Object) {
27 const QJsonObject languageToolObject = current.toObject();
28 LanguageToolGrammarError error;
29 error.parse(languageToolObject, -1);
30 if (error.isValid()) {
31 infos.append(error);
32 }
33 }
34 }
35 return infos;
36}
void error(QWidget *parent, const QString &text, const QString &title, const KGuiItem &buttonOk, Options options=Notify)
QJsonValue value(QLatin1StringView key) const const
QJsonArray toArray() const const
void append(QList< T > &&value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:02:03 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.