{"action":"created","comment":{"url":"https://api.github.com/repos/hyperledger/iroha/pulls/comments/86121496","pull_request_review_id":6794776,"id":86121496,"diff_hunk":"@@ -0,0 +1,108 @@\n+//\n+// Created by SonokoMizuki on 2016/11/02.\n+//\n+\n+#ifndef IROHA_JSON_PARSE_H\n+#define IROHA_JSON_PARSE_H\n+\n+#include \"../consensus/consensus_event.hpp\"\n+\n+// ***************8\n+// *\n+#include \"../vendor/json/src/json.hpp\"\n+// *\n+// ***************8\n+\n+\n+#include <type_traits>\n+#include <string>\n+#include <unordered_map>\n+\n+#include \"json_parse.hpp\"\n+\n+namespace json_parse {\n+\n+    template<\n+            typename T,\n+            typename U,\n+            std::enable_if_t<\n+                    std::is_base_of<consensus_event::ConsensusEvent<U>, T>::value,\n+                    std::nullptr_t\n+            > = nullptr\n+    >\n+    class JsonParse {\n+\n+       json dump_impl(Object obj) {\n+            json res;\n+            if(obj.getType() == Object::Type::DICT){\n+                for(auto&& o : obj.dictSub){\n+                    res[o.first] = dump_impl(o.second);\n+                }\n+            }else if(obj.getType() == Object::Type::LIST){\n+                res = json::array();\n+                for(auto&& o : obj.listSub){\n+                    res.push_back(dump_impl(o));\n+                }\n+            }else {\n+                if (obj.getType() == Object::Type::INT) {\n+                    res = std::to_string(obj.integer);\n+                } else if (obj.getType() == Object::Type::BOOL) {\n+                    res = obj.boolean ? \"true\" : \"false\";\n+                } else if (obj.getType() == Object::Type::STR) {\n+                    res = obj.str;\n+                } else if (obj.getType() == Object::Type::FLOAT) {\n+                    res = std::to_string(obj.floating);\n+                }\n+            }\n+            return res;\n+        }\n+\n+        Object load_impl(json j,Rule r){\n+            if(r.getType() == Type::DICT) {\n+                auto  dict = r.dictSub;\n+                Object res = Object(Type::DICT);\n+                for(const auto& kv : dict){\n+                    res.dictSub[kv.first] = load_impl( j[kv.first], dict[kv.first]);\n+                }\n+                return res;\n+            }else if(r.getType() == Type::LIST){\n+                auto  list = r.listSub;\n+                Object res = Object(Type::LIST);\n+                for(const auto& v : list){\n+                    res.listSub.push_back(load_impl( j.at(0), list));\n+                }\n+                return res;\n+            }else{\n+                if (r.getType() == Type::INT) {\n+                    return Object(Type::INT, j.get<int>());\n+                } else if (r.getType() == Type::BOOL) {\n+                    return Object(Type::BOOL, j.get<bool>());\n+                } else if (r.getType() == Type::STR) {\n+                    return Object(Type::STR, j.get<std::string>());\n+                } else if (obj.getType() == Type::FLOAT) {\n+                    return Object(Type::FLOAT, j.get<float>());\n+                }\n+            }\n+\n+        }\n+\n+        std::string dump(T consensusEvent) {\n+            json res;\n+            auto obj = consensusEvent.getJsonParseRule();\n+            return dump_impl(obj).dump();\n+        }\n+\n+        T load(std::string s) {","path":"core/service/json_parse_with_json_nlohmann.hpp","position":95,"original_position":95,"commit_id":"71a24d312fc3c3c8d8fd44ec0e81f642cbcfcd02","original_commit_id":"71a24d312fc3c3c8d8fd44ec0e81f642cbcfcd02","user":{"login":"takemiyamakoto","id":20982317,"avatar_url":"https://avatars.githubusercontent.com/u/20982317?v=3","gravatar_id":"","url":"https://api.github.com/users/takemiyamakoto","html_url":"https://github.com/takemiyamakoto","followers_url":"https://api.github.com/users/takemiyamakoto/followers","following_url":"https://api.github.com/users/takemiyamakoto/following{/other_user}","gists_url":"https://api.github.com/users/takemiyamakoto/gists{/gist_id}","starred_url":"https://api.github.com/users/takemiyamakoto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/takemiyamakoto/subscriptions","organizations_url":"https://api.github.com/users/takemiyamakoto/orgs","repos_url":"https://api.github.com/users/takemiyamakoto/repos","events_url":"https://api.github.com/users/takemiyamakoto/events{/privacy}","received_events_url":"https://api.github.com/users/takemiyamakoto/received_events","type":"User","site_admin":false},"body":"![Codacy](https://www.codacy.com/assets/images/favicon.png) Issue found: [Unused private function: 'JsonParse::load'](https://www.codacy.com/app/soramitsu/iroha/file/4345543374/issues/source?bid=3712491&fileBranchId=3870372#l95)","created_at":"2016-11-02T11:34:41Z","updated_at":"2016-11-02T11:34:41Z","html_url":"https://github.com/hyperledger/iroha/pull/52#discussion_r86121496","pull_request_url":"https://api.github.com/repos/hyperledger/iroha/pulls/52","_links":{"self":{"href":"https://api.github.com/repos/hyperledger/iroha/pulls/comments/86121496"},"html":{"href":"https://github.com/hyperledger/iroha/pull/52#discussion_r86121496"},"pull_request":{"href":"https://api.github.com/repos/hyperledger/iroha/pulls/52"}}},"pull_request":{"url":"https://api.github.com/repos/hyperledger/iroha/pulls/52","id":91951536,"html_url":"https://github.com/hyperledger/iroha/pull/52","diff_url":"https://github.com/hyperledger/iroha/pull/52.diff","patch_url":"https://github.com/hyperledger/iroha/pull/52.patch","issue_url":"https://api.github.com/repos/hyperledger/iroha/issues/52","number":52,"state":"closed","locked":false,"title":"Develop","user":{"login":"takemiyamakoto","id":20982317,"avatar_url":"https://avatars.githubusercontent.com/u/20982317?v=3","gravatar_id":"","url":"https://api.github.com/users/takemiyamakoto","html_url":"https://github.com/takemiyamakoto","followers_url":"https://api.github.com/users/takemiyamakoto/followers","following_url":"https://api.github.com/users/takemiyamakoto/following{/other_user}","gists_url":"https://api.github.com/users/takemiyamakoto/gists{/gist_id}","starred_url":"https://api.github.com/users/takemiyamakoto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/takemiyamakoto/subscriptions","organizations_url":"https://api.github.com/users/takemiyamakoto/orgs","repos_url":"https://api.github.com/users/takemiyamakoto/repos","events_url":"https://api.github.com/users/takemiyamakoto/events{/privacy}","received_events_url":"https://api.github.com/users/takemiyamakoto/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-02T11:23:05Z","updated_at":"2016-11-02T11:34:42Z","closed_at":"2016-11-02T11:31:18Z","merged_at":null,"merge_commit_sha":"1c4ea22c6395acce7a9d99c91be20deb7bd73b7f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/hyperledger/iroha/pulls/52/commits","review_comments_url":"https://api.github.com/repos/hyperledger/iroha/pulls/52/comments","review_comment_url":"https://api.github.com/repos/hyperledger/iroha/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hyperledger/iroha/issues/52/comments","statuses_url":"https://api.github.com/repos/hyperledger/iroha/statuses/71a24d312fc3c3c8d8fd44ec0e81f642cbcfcd02","head":{"label":"hyperledger:develop","ref":"develop","sha":"71a24d312fc3c3c8d8fd44ec0e81f642cbcfcd02","user":{"login":"hyperledger","id":7657900,"avatar_url":"https://avatars.githubusercontent.com/u/7657900?v=3","gravatar_id":"","url":"https://api.github.com/users/hyperledger","html_url":"https://github.com/hyperledger","followers_url":"https://api.github.com/users/hyperledger/followers","following_url":"https://api.github.com/users/hyperledger/following{/other_user}","gists_url":"https://api.github.com/users/hyperledger/gists{/gist_id}","starred_url":"https://api.github.com/users/hyperledger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hyperledger/subscriptions","organizations_url":"https://api.github.com/users/hyperledger/orgs","repos_url":"https://api.github.com/users/hyperledger/repos","events_url":"https://api.github.com/users/hyperledger/events{/privacy}","received_events_url":"https://api.github.com/users/hyperledger/received_events","type":"Organization","site_admin":false},"repo":{"id":67340575,"name":"iroha","full_name":"hyperledger/iroha","owner":{"login":"hyperledger","id":7657900,"avatar_url":"https://avatars.githubusercontent.com/u/7657900?v=3","gravatar_id":"","url":"https://api.github.com/users/hyperledger","html_url":"https://github.com/hyperledger","followers_url":"https://api.github.com/users/hyperledger/followers","following_url":"https://api.github.com/users/hyperledger/following{/other_user}","gists_url":"https://api.github.com/users/hyperledger/gists{/gist_id}","starred_url":"https://api.github.com/users/hyperledger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hyperledger/subscriptions","organizations_url":"https://api.github.com/users/hyperledger/orgs","repos_url":"https://api.github.com/users/hyperledger/repos","events_url":"https://api.github.com/users/hyperledger/events{/privacy}","received_events_url":"https://api.github.com/users/hyperledger/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hyperledger/iroha","description":"Iroha - A simple, decentralized ledger","fork":false,"url":"https://api.github.com/repos/hyperledger/iroha","forks_url":"https://api.github.com/repos/hyperledger/iroha/forks","keys_url":"https://api.github.com/repos/hyperledger/iroha/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hyperledger/iroha/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hyperledger/iroha/teams","hooks_url":"https://api.github.com/repos/hyperledger/iroha/hooks","issue_events_url":"https://api.github.com/repos/hyperledger/iroha/issues/events{/number}","events_url":"https://api.github.com/repos/hyperledger/iroha/events","assignees_url":"https://api.github.com/repos/hyperledger/iroha/assignees{/user}","branches_url":"https://api.github.com/repos/hyperledger/iroha/branches{/branch}","tags_url":"https://api.github.com/repos/hyperledger/iroha/tags","blobs_url":"https://api.github.com/repos/hyperledger/iroha/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hyperledger/iroha/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hyperledger/iroha/git/refs{/sha}","trees_url":"https://api.github.com/repos/hyperledger/iroha/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hyperledger/iroha/statuses/{sha}","languages_url":"https://api.github.com/repos/hyperledger/iroha/languages","stargazers_url":"https://api.github.com/repos/hyperledger/iroha/stargazers","contributors_url":"https://api.github.com/repos/hyperledger/iroha/contributors","subscribers_url":"https://api.github.com/repos/hyperledger/iroha/subscribers","subscription_url":"https://api.github.com/repos/hyperledger/iroha/subscription","commits_url":"https://api.github.com/repos/hyperledger/iroha/commits{/sha}","git_commits_url":"https://api.github.com/repos/hyperledger/iroha/git/commits{/sha}","comments_url":"https://api.github.com/repos/hyperledger/iroha/comments{/number}","issue_comment_url":"https://api.github.com/repos/hyperledger/iroha/issues/comments{/number}","contents_url":"https://api.github.com/repos/hyperledger/iroha/contents/{+path}","compare_url":"https://api.github.com/repos/hyperledger/iroha/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hyperledger/iroha/merges","archive_url":"https://api.github.com/repos/hyperledger/iroha/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hyperledger/iroha/downloads","issues_url":"https://api.github.com/repos/hyperledger/iroha/issues{/number}","pulls_url":"https://api.github.com/repos/hyperledger/iroha/pulls{/number}","milestones_url":"https://api.github.com/repos/hyperledger/iroha/milestones{/number}","notifications_url":"https://api.github.com/repos/hyperledger/iroha/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hyperledger/iroha/labels{/name}","releases_url":"https://api.github.com/repos/hyperledger/iroha/releases{/id}","deployments_url":"https://api.github.com/repos/hyperledger/iroha/deployments","created_at":"2016-09-04T11:17:53Z","updated_at":"2016-11-01T22:32:59Z","pushed_at":"2016-11-02T11:31:41Z","git_url":"git://github.com/hyperledger/iroha.git","ssh_url":"git@github.com:hyperledger/iroha.git","clone_url":"https://github.com/hyperledger/iroha.git","svn_url":"https://github.com/hyperledger/iroha","homepage":"http://iroha.tech","size":19948,"stargazers_count":29,"watchers_count":29,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":7,"forks":5,"open_issues":7,"watchers":29,"default_branch":"master"}},"base":{"label":"hyperledger:master","ref":"master","sha":"d09d42463068389e6b8c43bb292d04c1f42aa0cd","user":{"login":"hyperledger","id":7657900,"avatar_url":"https://avatars.githubusercontent.com/u/7657900?v=3","gravatar_id":"","url":"https://api.github.com/users/hyperledger","html_url":"https://github.com/hyperledger","followers_url":"https://api.github.com/users/hyperledger/followers","following_url":"https://api.github.com/users/hyperledger/following{/other_user}","gists_url":"https://api.github.com/users/hyperledger/gists{/gist_id}","starred_url":"https://api.github.com/users/hyperledger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hyperledger/subscriptions","organizations_url":"https://api.github.com/users/hyperledger/orgs","repos_url":"https://api.github.com/users/hyperledger/repos","events_url":"https://api.github.com/users/hyperledger/events{/privacy}","received_events_url":"https://api.github.com/users/hyperledger/received_events","type":"Organization","site_admin":false},"repo":{"id":67340575,"name":"iroha","full_name":"hyperledger/iroha","owner":{"login":"hyperledger","id":7657900,"avatar_url":"https://avatars.githubusercontent.com/u/7657900?v=3","gravatar_id":"","url":"https://api.github.com/users/hyperledger","html_url":"https://github.com/hyperledger","followers_url":"https://api.github.com/users/hyperledger/followers","following_url":"https://api.github.com/users/hyperledger/following{/other_user}","gists_url":"https://api.github.com/users/hyperledger/gists{/gist_id}","starred_url":"https://api.github.com/users/hyperledger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hyperledger/subscriptions","organizations_url":"https://api.github.com/users/hyperledger/orgs","repos_url":"https://api.github.com/users/hyperledger/repos","events_url":"https://api.github.com/users/hyperledger/events{/privacy}","received_events_url":"https://api.github.com/users/hyperledger/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hyperledger/iroha","description":"Iroha - A simple, decentralized ledger","fork":false,"url":"https://api.github.com/repos/hyperledger/iroha","forks_url":"https://api.github.com/repos/hyperledger/iroha/forks","keys_url":"https://api.github.com/repos/hyperledger/iroha/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hyperledger/iroha/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hyperledger/iroha/teams","hooks_url":"https://api.github.com/repos/hyperledger/iroha/hooks","issue_events_url":"https://api.github.com/repos/hyperledger/iroha/issues/events{/number}","events_url":"https://api.github.com/repos/hyperledger/iroha/events","assignees_url":"https://api.github.com/repos/hyperledger/iroha/assignees{/user}","branches_url":"https://api.github.com/repos/hyperledger/iroha/branches{/branch}","tags_url":"https://api.github.com/repos/hyperledger/iroha/tags","blobs_url":"https://api.github.com/repos/hyperledger/iroha/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hyperledger/iroha/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hyperledger/iroha/git/refs{/sha}","trees_url":"https://api.github.com/repos/hyperledger/iroha/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hyperledger/iroha/statuses/{sha}","languages_url":"https://api.github.com/repos/hyperledger/iroha/languages","stargazers_url":"https://api.github.com/repos/hyperledger/iroha/stargazers","contributors_url":"https://api.github.com/repos/hyperledger/iroha/contributors","subscribers_url":"https://api.github.com/repos/hyperledger/iroha/subscribers","subscription_url":"https://api.github.com/repos/hyperledger/iroha/subscription","commits_url":"https://api.github.com/repos/hyperledger/iroha/commits{/sha}","git_commits_url":"https://api.github.com/repos/hyperledger/iroha/git/commits{/sha}","comments_url":"https://api.github.com/repos/hyperledger/iroha/comments{/number}","issue_comment_url":"https://api.github.com/repos/hyperledger/iroha/issues/comments{/number}","contents_url":"https://api.github.com/repos/hyperledger/iroha/contents/{+path}","compare_url":"https://api.github.com/repos/hyperledger/iroha/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hyperledger/iroha/merges","archive_url":"https://api.github.com/repos/hyperledger/iroha/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hyperledger/iroha/downloads","issues_url":"https://api.github.com/repos/hyperledger/iroha/issues{/number}","pulls_url":"https://api.github.com/repos/hyperledger/iroha/pulls{/number}","milestones_url":"https://api.github.com/repos/hyperledger/iroha/milestones{/number}","notifications_url":"https://api.github.com/repos/hyperledger/iroha/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hyperledger/iroha/labels{/name}","releases_url":"https://api.github.com/repos/hyperledger/iroha/releases{/id}","deployments_url":"https://api.github.com/repos/hyperledger/iroha/deployments","created_at":"2016-09-04T11:17:53Z","updated_at":"2016-11-01T22:32:59Z","pushed_at":"2016-11-02T11:31:41Z","git_url":"git://github.com/hyperledger/iroha.git","ssh_url":"git@github.com:hyperledger/iroha.git","clone_url":"https://github.com/hyperledger/iroha.git","svn_url":"https://github.com/hyperledger/iroha","homepage":"http://iroha.tech","size":19948,"stargazers_count":29,"watchers_count":29,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":7,"forks":5,"open_issues":7,"watchers":29,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hyperledger/iroha/pulls/52"},"html":{"href":"https://github.com/hyperledger/iroha/pull/52"},"issue":{"href":"https://api.github.com/repos/hyperledger/iroha/issues/52"},"comments":{"href":"https://api.github.com/repos/hyperledger/iroha/issues/52/comments"},"review_comments":{"href":"https://api.github.com/repos/hyperledger/iroha/pulls/52/comments"},"review_comment":{"href":"https://api.github.com/repos/hyperledger/iroha/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hyperledger/iroha/pulls/52/commits"},"statuses":{"href":"https://api.github.com/repos/hyperledger/iroha/statuses/71a24d312fc3c3c8d8fd44ec0e81f642cbcfcd02"}}}}
{"actor":{"display_login":"takemiyamakoto"}}