Use push_back of nlohmann::json_pointer if available.

This commit is contained in:
Patrick Boettcher 2019-01-24 12:25:47 +01:00
parent e8a9f66b1d
commit 746394922a
3 changed files with 7 additions and 4 deletions

View File

@ -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).

View File

@ -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;
}

View File

@ -1023,7 +1023,7 @@ std::shared_ptr<schema> schema::make(json &schema,
// append to all URIs the keys for this sub-schema
for (auto &key : keys)
for (auto &uri : uris)
uri = uri.append(json_uri::escape(key));
uri = uri.append(key);
std::shared_ptr<::schema> sch;