From 746394922a6b0e595fa8e17341a3fde075cf118e Mon Sep 17 00:00:00 2001 From: Patrick Boettcher
Date: Thu, 24 Jan 2019 12:25:47 +0100
Subject: [PATCH] Use push_back of nlohmann::json_pointer if available.
---
README.md | 4 +---
src/json-schema.hpp | 5 +++++
src/json-validator.cpp | 2 +-
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index 691af12..65c5692 100644
--- a/README.md
+++ b/README.md
@@ -34,8 +34,6 @@ is parsed into compiled C++ objects which are then used during validation. There
still optimizations to be done, but validation speed has improved by factor 100
or more.
-In JSON-schema one sub-schema can be
-
# Design goals
The main goal of this validator is to produce *human-comprehensible* error
@@ -44,7 +42,7 @@ messages if a JSON-document/instance does not comply to its schema.
By default this is done with exceptions thrown at the users with a helpful
message telling what's wrong with the document while validating.
-With **2.0.0** the user can passed a `json_scheam::basic_error_handler` derived object
+With **2.0.0** the user can pass a `json_scheam::basic_error_handler` derived object
along with the instance to validate to receive a each time a validation error occurs
and decice what to do (throwing, counting, collecting).
diff --git a/src/json-schema.hpp b/src/json-schema.hpp
index 853282a..22c15f1 100644
--- a/src/json-schema.hpp
+++ b/src/json-schema.hpp
@@ -92,7 +92,12 @@ public:
json_uri append(const std::string &field) const
{
json_uri u = *this;
+#if NLOHMANN_JSON_VERSION_MAJOR >= 3 && NLOHMANN_JSON_VERSION_MINOR >= 5 && NLOHMANN_JSON_VERSION_PATCH >= 1
+ u.pointer_.push_back(field);
+#else
u.pointer_ = nlohmann::json::json_pointer(u.pointer_.to_string() + '/' + escape(field));
+#endif
+
return u;
}
diff --git a/src/json-validator.cpp b/src/json-validator.cpp
index 96a439d..4ca00d8 100644
--- a/src/json-validator.cpp
+++ b/src/json-validator.cpp
@@ -1023,7 +1023,7 @@ std::shared_ptr