diff cpp/json_util/json_util.hpp @ 656:734ce3a26a58

json_util: upgrade to 3.5.0 and add string_view overload
author David Demelier <markand@malikania.fr>
date Mon, 21 Jan 2019 20:45:02 +0100
parents a0239cca29fa
children
line wrap: on
line diff
--- a/cpp/json_util/json_util.hpp	Mon Jan 21 20:39:31 2019 +0100
+++ b/cpp/json_util/json_util.hpp	Mon Jan 21 20:45:02 2019 +0100
@@ -103,6 +103,20 @@
 };
 
 /**
+ * \brief Specialization for `std::string_view`.
+ */
+template <>
+struct type_traits<std::string_view> {
+	/**
+	 * Convert the JSON value to std::string.
+	 *
+	 * \param value the value
+	 * \return the string or empty if not a string type
+	 */
+	static auto get(const nlohmann::json& value) -> std::optional<std::string_view>;
+};
+
+/**
  * \brief Specialization for `std::int8_t`.
  */
 template <>