/** * @file include/server/MpackJson.h * @brief MPack<>JSON converter * @copyright 2015 Dual Inventive Technology Centre B.V. * * it converts JSON to MPack and MPack to JSON. */ #ifndef INCLUDE_SERVER_MPACKJSON_H_ #define INCLUDE_SERVER_MPACKJSON_H_ #include #include #include #include /** * @class MpackJson * it converts JSON to MPack and MPack to JSON */ class MpackJson { private: /** * Converts an MPack node API object to a Json object * @param mp MPack node type object * @return Json object */ static std::shared_ptr toJsonObject(const mpack_node_t &mp); /** * Converts an MPack node API array to a Json array * @param mp MPack node type array * @return Json object */ static std::shared_ptr toJsonArray(const mpack_node_t &mp); /** * Converts a JSON object into an MPack object with the MPack writer API * @param writer MPack writer * @param mp Incoming Json object */ static void toMpackObject(mpack_writer_t *writer, std::shared_ptr mp); /** * Converts a JSON array into an MPack array with the MPack writer API * @param writer MPack writer * @param mp Incoming Json array */ static void toMpackArray(mpack_writer_t *writer, std::shared_ptr mp); public: /** * Converts MPack to JSON * @param mpack Incoming MPack string * @param json Outcoming JSON string * @return 0 on success or error code */ static int mpackToJson(const Di::Buffer &mpack, std::shared_ptr *json); /** * Converts JSON to MPack * @param json Incoming JSON string * @param mpack Outcoming MPack string * @return 0 on success or error code */ static int jsonToMpack(const std::shared_ptr &json, std::shared_ptr mpack); }; #endif // INCLUDE_SERVER_MPACKJSON_H_