Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/miloyip/rapidjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbogaotory <gaoblin@gmail.com>2018-06-01 23:16:26 +0300
committerbogaotory <gaoblin@gmail.com>2018-06-01 23:16:26 +0300
commit6f7dcb30d9d662bada0e7e2ebd75846b8c5b91f3 (patch)
tree5d3196ec092fdc48ab84a3c3ca87add0b7b5da11 /include/rapidjson/schema.h
parentfa98b5b4b67af335655a8b6843a9d82ae4b731a5 (diff)
again, in relation to solving issue #784, use `SizeType`-typed variable to indicate a none-zero length string has been given in the schema as default value for the json property; added an unittest `Object_Required_PassWithDefault`
Diffstat (limited to 'include/rapidjson/schema.h')
-rw-r--r--include/rapidjson/schema.h15
1 files changed, 5 insertions, 10 deletions
diff --git a/include/rapidjson/schema.h b/include/rapidjson/schema.h
index ab554523..dc0af780 100644
--- a/include/rapidjson/schema.h
+++ b/include/rapidjson/schema.h
@@ -441,7 +441,7 @@ public:
maxLength_(~SizeType(0)),
exclusiveMinimum_(false),
exclusiveMaximum_(false),
- defaultValue_()
+ defaultValueLength_(0)
{
typedef typename SchemaDocumentType::ValueType ValueType;
typedef typename ValueType::ConstValueIterator ConstValueIterator;
@@ -640,7 +640,7 @@ public:
// Default
if (const ValueType* v = GetMember(value, GetDefaultValueString()))
if (v->IsString())
- defaultValue_ = v->GetString();
+ defaultValueLength_ = v->GetStringLength();
}
@@ -942,14 +942,9 @@ public:
if (hasRequired_) {
context.error_handler.StartMissingProperties();
for (SizeType index = 0; index < propertyCount_; index++)
- if (properties_[index].required && !context.propertyExist[index]){
- if (properties_[index].schema->defaultValue_.empty() || properties_[index].schema->defaultValue_ == "" ){
+ if (properties_[index].required && !context.propertyExist[index])
+ if (properties_[index].schema->defaultValueLength_ == 0 )
context.error_handler.AddMissingProperty(properties_[index].name);
- } else {
- // std::cout << "default value of " << properties_[index].name.GetString()
- // << " is:" << properties_[index].schema->defaultValue_ << "\n";
- }
- }
if (context.error_handler.EndMissingProperties())
RAPIDJSON_INVALID_KEYWORD_RETURN(GetRequiredString());
}
@@ -1441,7 +1436,7 @@ private:
bool exclusiveMinimum_;
bool exclusiveMaximum_;
- std::string defaultValue_;
+ SizeType defaultValueLength_;
};
template<typename Stack, typename Ch>