1 //! \file CacheJsonToArticleConverter.cpp
3 #include "CacheJsonToArticleConverter.h"
7 #include "WalkerException.h"
10 ArticleCollection
& CacheJsonToArticleConverter::convertToArticle(std::string json
,
11 ArticleCollection
& articleCache
)
15 bool success
= reader
.parse(json
, document
, false);
18 throw WalkerException("Error parsing JSON");
21 // get all "main" articles first
22 for(auto& titleElement
: document
.getMemberNames()) {
23 std::string title
= titleElement
;
25 Article
* a
= articleCache
.get(title
);
28 a
= new Article(title
);
33 .get(title
, Json::Value::nullSingleton())
34 .get("forward_links", Json::Value::nullSingleton());
37 /* don't need to set article analyzed to false,
38 * since that's the default */
44 for(auto linkedArticle
: links
) {
45 std::string linkedTitle
= linkedArticle
.asString();
46 Article
* la
= articleCache
.get(linkedTitle
);
49 la
= new Article(linkedTitle
);
59 a->setAnalyzed(true); ?