From 9d9fbc91f9593e839460952eefa1887a5c9231c0 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 11 Oct 2023 15:45:27 +0200 Subject: [PATCH] Read Project, Version and Info fields from json-tariff-files --- library/src/configuration.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/library/src/configuration.cpp b/library/src/configuration.cpp index ea5f587..59cd6e8 100644 --- a/library/src/configuration.cpp +++ b/library/src/configuration.cpp @@ -1,4 +1,5 @@ #include "configuration.h" +#include /// MemberType Configuration::IdentifyJsonMember(const char* member_name) @@ -87,13 +88,24 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json) const char* mb_name = i->name.GetString(); if (mb_name == NULL) continue; - // if (!document[mb_name].IsArray()) { - std::string const _mb_name(mb_name); - if (_mb_name == "version" || _mb_name == "project" || - _mb_name == "zone" || _mb_name == "info") { + if (document[mb_name].IsString()) { + QString const _mb_name(mb_name); + if (_mb_name.startsWith("Project", Qt::CaseInsensitive)) { + cfg->project.project = document[mb_name].GetString(); + qDebug() << "PROJECT" << cfg->project.project; continue; } - // } + if (_mb_name.startsWith("Version", Qt::CaseInsensitive)) { + cfg->project.version = document[mb_name].GetString(); + qDebug() << "VERSION" << cfg->project.version; + continue; + } + if (_mb_name.startsWith("Info", Qt::CaseInsensitive)) { + cfg->project.info = document[mb_name].GetString(); + qDebug() << "INFO" << cfg->project.info; + continue; + } + } //printf(" -%s\n", mb_name);