Skip to content

Instantly share code, notes, and snippets.

@schani
Created November 8, 2018 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schani/1b5cd956d4fdc900809b5a32b96438a4 to your computer and use it in GitHub Desktop.
Save schani/1b5cd956d4fdc900809b5a32b96438a4 to your computer and use it in GitHub Desktop.
diff -Naur /tmp/tmp.JgQbRnLgcP/cplusplus/test/inputs/json/samples/pokedex/TopLevel.hpp /tmp/tmp.wYD9u6A3yU/cplusplus/test/inputs/json/samples/pokedex/TopLevel.hpp
--- /tmp/tmp.JgQbRnLgcP/cplusplus/test/inputs/json/samples/pokedex/TopLevel.hpp 2018-11-06 16:47:56.000000000 +0000
+++ /tmp/tmp.wYD9u6A3yU/cplusplus/test/inputs/json/samples/pokedex/TopLevel.hpp 2018-11-08 01:40:36.000000000 +0000
@@ -14,6 +14,7 @@
#include <boost/optional.hpp>
#include <stdexcept>
#include <regex>
+
namespace nlohmann {
template <typename T>
struct adl_serializer<std::shared_ptr<T>> {
@@ -45,6 +46,11 @@
return std::shared_ptr<T>();
}
+ template <typename T>
+ inline std::shared_ptr<T> get_optional(const json &j, std::string property) {
+ return get_optional<T>(j, property.data());
+ }
+
enum class Egg : int { NOT_IN_EGGS, OMANYTE_CANDY, THE_10_KM, THE_2_KM, THE_5_KM };
class Evolution {
@@ -174,6 +180,21 @@
}
namespace nlohmann {
+ void from_json(const json& _j, quicktype::Evolution& _x);
+ void to_json(json& _j, const quicktype::Evolution& _x);
+
+ void from_json(const json& _j, quicktype::Pokemon& _x);
+ void to_json(json& _j, const quicktype::Pokemon& _x);
+
+ void from_json(const json& _j, quicktype::TopLevel& _x);
+ void to_json(json& _j, const quicktype::TopLevel& _x);
+
+ void from_json(const json& _j, quicktype::Egg& _x);
+ void to_json(json& _j, const quicktype::Egg& _x);
+
+ void from_json(const json& _j, quicktype::Type& _x);
+ void to_json(json& _j, const quicktype::Type& _x);
+
inline void from_json(const json& _j, quicktype::Evolution& _x) {
_x.set_name( _j.at("name").get<std::string>() );
_x.set_num( _j.at("num").get<std::string>() );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment