KItinerary

json/jsonld.cpp
1/*
2 SPDX-FileCopyrightText: 2023 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#include "jsonld.h"
7
8#include <QJsonObject>
9#include <QString>
10
11using namespace Qt::Literals::StringLiterals;
12
13using namespace KItinerary;
14
16{
17 return normalizeTypeName(obj.value("@type"_L1).toString());
18}
19
20QString JsonLd::normalizeTypeName(QString &&typeName)
21{
22 // strip fully qualified names
23 if (typeName.startsWith("http://schema.org/"_L1)) {
24 typeName = typeName.mid(18);
25 } else if (typeName.startsWith("https://schema.org/"_L1)) {
26 typeName = typeName.mid(19);
27 }
28 return typeName;
29}
30
32{
33 return uri.startsWith("http://schema.org"_L1) || uri.startsWith("https://schema.org"_L1);
34}
QString typeName(const QJsonObject &obj)
Normalized type name from object.
bool isSchemaOrgNamespace(QStringView uri)
Checks whether uri is in the http://schema.org namespace.
Classes for reservation/travel data models, data extraction and data augmentation.
Definition berelement.h:17
KOSM_EXPORT const char * typeName(Type type)
QJsonValue value(QLatin1StringView key) const const
QString toString() const const
bool startsWith(QChar ch) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 4 2024 12:00:25 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.