mirror of
https://github.com/tristanpenman/valijson.git
synced 2025-03-03 12:58:03 +01:00
Merge remote-tracking branch 'origin/master' into v6-and-v7-support
This commit is contained in:
commit
8febb456f4
@ -15,13 +15,13 @@ namespace internal {
|
||||
namespace json_pointer {
|
||||
|
||||
/**
|
||||
* @brief Replace all occurrences of `search` with `replace`. Modifies `subject` in place
|
||||
* @brief Replace all occurrences of `search` with `replace`. Modifies `subject` in place.
|
||||
*
|
||||
* @param subject string to operate on
|
||||
* @param search string to search
|
||||
* @param replace replacement string
|
||||
*/
|
||||
inline void replace_all_inplace(std::string& subject, const char* search,
|
||||
inline void replaceAllInPlace(std::string& subject, const char* search,
|
||||
const char* replace)
|
||||
{
|
||||
size_t pos = 0;
|
||||
@ -94,8 +94,8 @@ inline std::string extractReferenceToken(std::string::const_iterator begin,
|
||||
std::string token(begin, end);
|
||||
|
||||
// Replace JSON Pointer-specific escaped character sequences
|
||||
replace_all_inplace(token, "~1", "/");
|
||||
replace_all_inplace(token, "~0", "~");
|
||||
replaceAllInPlace(token, "~1", "/");
|
||||
replaceAllInPlace(token, "~0", "~");
|
||||
|
||||
// Replace %-encoded character sequences with their actual characters
|
||||
for (size_t n = token.find('%'); n != std::string::npos;
|
||||
|
@ -967,9 +967,16 @@ public:
|
||||
if (!additionalPropertiesSubschema) {
|
||||
if (propertiesMatched.size() != target.getObjectSize()) {
|
||||
if (results) {
|
||||
results->pushError(context, "Object contains properties "
|
||||
std::string unwanted;
|
||||
for (const typename AdapterType::ObjectMember m : object) {
|
||||
if (propertiesMatched.find(m.first) == propertiesMatched.end()) {
|
||||
unwanted = m.first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
results->pushError(context, "Object contains a property "
|
||||
"that could not be validated using 'properties' "
|
||||
"or 'additionalProperties' constraints");
|
||||
"or 'additionalProperties' constraints: '" + unwanted + "'.");
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -12,7 +12,7 @@ TEST_F(TestJsonCppAdapter, BasicArrayIteration)
|
||||
{
|
||||
const unsigned int numElements = 10;
|
||||
|
||||
// Create a rapidjson document that consists of an array of numbers
|
||||
// Create a jsoncpp document that consists of an array of numbers
|
||||
Json::Value document(Json::arrayValue);
|
||||
for (unsigned int i = 0; i < numElements; i++) {
|
||||
document.append(Json::Value(i));
|
||||
@ -46,7 +46,7 @@ TEST_F(TestJsonCppAdapter, BasicObjectIteration)
|
||||
{
|
||||
const unsigned int numElements = 10;
|
||||
|
||||
// Create a rapidjson document that consists of an object that maps numeric
|
||||
// Create a jsoncpp document that consists of an object that maps numeric
|
||||
// strings their corresponding numeric values
|
||||
Json::Value document(Json::objectValue);
|
||||
for (unsigned int i = 0; i < numElements; i++) {
|
||||
|
@ -12,7 +12,7 @@ TEST_F(TestPropertyTreeAdapter, BasicArrayIteration)
|
||||
{
|
||||
const unsigned int numElements = 10;
|
||||
|
||||
// Create a boost property that is equivalent to a JSON array containing a
|
||||
// Create a boost property tree that is equivalent to a JSON array containing a
|
||||
// list of numbers.
|
||||
boost::property_tree::ptree document;
|
||||
for (unsigned int i = 0; i < numElements; i++) {
|
||||
@ -50,7 +50,7 @@ TEST_F(TestPropertyTreeAdapter, BasicObjectIteration)
|
||||
{
|
||||
const unsigned int numElements = 10;
|
||||
|
||||
// Create a rapidjson document that consists of an object that maps numeric
|
||||
// Create a boost property tree that consists of an object that maps numeric
|
||||
// strings their corresponding numeric values
|
||||
boost::property_tree::ptree document;
|
||||
for (unsigned int i = 0; i < numElements; i++) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user