Add a set of helper functions to support JSON reading/writing

Change-Id: I93b3cd78efd9b04102f4928be99dfbe20f30e355
diff --git a/src/json-helper.hpp b/src/json-helper.hpp
new file mode 100644
index 0000000..fe3ba80
--- /dev/null
+++ b/src/json-helper.hpp
@@ -0,0 +1,106 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2017, Regents of the University of California.
+ *
+ * This file is part of ndncert, a certificate management system based on NDN.
+ *
+ * ndncert is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License along with
+ * ndncert, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndncert authors and contributors.
+ */
+
+#ifndef NDNCERT_JSON_HELPER_HPP
+#define NDNCERT_JSON_HELPER_HPP
+
+#include "certificate-request.hpp"
+
+namespace ndn {
+namespace ndncert {
+
+const std::string JSON_IDNENTIFIER = "Identifier";
+const std::string JSON_CA_INFO = "CA-Info";
+const std::string JSON_STATUS = "Status";
+const std::string JSON_REQUEST_ID = "Request-ID";
+const std::string JSON_CHALLENGES = "Challenges";
+const std::string JSON_CHALLENGE_TYPE = "Challenge-Type";
+const std::string JSON_CHALLENGE_INSTRUCTION = "Challenge-Instruction";
+const std::string JSON_CHALLENGE_STATUS = "Challenge-Status";
+const std::string JSON_ERROR_INFO = "Error-Info";
+
+typedef boost::property_tree::ptree JsonSection;
+
+/**
+ * @brief Generate JSON file to response PROBE insterest
+ *
+ * Target JSON format:
+ * {
+ *   "Identifier": "",
+ *   "CA-Info": ""
+ * }
+ */
+const JsonSection
+genResponseProbeJson(const Name& identifier, const Name& CaInformation);
+
+/**
+ * @brief Generate JSON file to response NEW interest
+ *
+ * Target JSON format:
+ * {
+ *   "Status": "",
+ *   "Request-ID": "",
+ *   "Challenges": [
+ *     {
+ *       "Challenge-Type": "",
+ *       "Challenge-Instruction": ""
+ *     },
+ *     {
+ *       "Challenge-Type": "",
+ *       "Challenge-Instruction": ""
+ *     },
+ *     ...
+ *   ]
+ * }
+ */
+const JsonSection
+genResponseNewJson(const CertificateRequest& request,
+                   const std::list<std::tuple<std::string, std::string>> challenges);
+
+/**
+ * @brief Generate JSON file to response POLL interest
+ *
+ * Target JSON format:
+ * {
+ *   "Status": "",
+ *   "Challenge-Type": "",
+ *   "Challenge-Status": "",
+ *   "Challenge-Instruction": ""
+ * }
+ */
+const JsonSection
+genResponsePollJson(const CertificateRequest& request);
+
+/**
+ * @brief Generate JSON file when there is an Error
+ *
+ * Target JSON format:
+ * {
+ *   "Status": "",
+ *   "Error-Info": ""
+ * }
+ */
+const JsonSection
+genErrorJson(const std::string& errorInfo);
+
+} // namespace ndncert
+} // namespace ndn
+
+#endif // NDNCERT_JSON_HELPER_HPP