From d806a2d2c1025bccef2a5044208cc374f968b0f0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andreas=20D=C3=BCring?= Date: Tue, 17 Apr 2018 20:20:36 +0200 Subject: [PATCH] if branch for links json data --- src/WikimediaJsonToArticleConverter.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/WikimediaJsonToArticleConverter.cpp b/src/WikimediaJsonToArticleConverter.cpp index 069e2a5..e8cdc82 100644 --- a/src/WikimediaJsonToArticleConverter.cpp +++ b/src/WikimediaJsonToArticleConverter.cpp @@ -55,21 +55,23 @@ namespace WikiWalker // add links //! \todo support linkshere std::shared_ptr
par; - for(const auto& linked : - onePage.get("links", Json::Value::nullSingleton())) { - auto linkedPageTitle = - linked.get("title", Json::Value::nullSingleton()).asString(); - par = CollectionUtils::get(articleCache, linkedPageTitle); - - if(par == nullptr) { - par = std::make_shared
(linkedPageTitle); - CollectionUtils::add(articleCache, par); + if(onePage.isMember("links")) { + for(const auto& linked : + onePage.get("links", Json::Value::nullSingleton())) { + auto linkedPageTitle = + linked.get("title", Json::Value::nullSingleton()).asString(); + par = CollectionUtils::get(articleCache, linkedPageTitle); + + if(par == nullptr) { + par = std::make_shared
(linkedPageTitle); + CollectionUtils::add(articleCache, par); + } + + wantedArticle->addLink(par); } - wantedArticle->addLink(par); + wantedArticle->analyzed(true); } - - wantedArticle->analyzed(true); } bool moreData; -- 2.11.4.GIT