mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-03-04 07:27:22 +01:00
partially revert 'Added features that allow the reader to accept common non-standard JSON.'
revert '642befc836ac5093b528e7d8b4fd66b66735a98c', but keep the *added* methods for `decodedNumber()` and `decodedDouble()`.
This commit is contained in:
parent
93f45d065c
commit
f4bdc1b602
@ -44,12 +44,6 @@ public:
|
|||||||
/// \c true if root must be either an array or an object value. Default: \c
|
/// \c true if root must be either an array or an object value. Default: \c
|
||||||
/// false.
|
/// false.
|
||||||
bool strictRoot_;
|
bool strictRoot_;
|
||||||
|
|
||||||
/// \c true if dropped null placeholders are allowed. Default: \c false.
|
|
||||||
bool allowDroppedNullPlaceholders_;
|
|
||||||
|
|
||||||
/// \c true if numeric object key are allowed. Default: \c false.
|
|
||||||
bool allowNumericKeys_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Json
|
} // namespace Json
|
||||||
|
@ -42,17 +42,14 @@ typedef std::auto_ptr<CharReader> CharReaderPtr;
|
|||||||
// ////////////////////////////////
|
// ////////////////////////////////
|
||||||
|
|
||||||
Features::Features()
|
Features::Features()
|
||||||
: allowComments_(true), strictRoot_(false),
|
: allowComments_(true), strictRoot_(false)
|
||||||
allowDroppedNullPlaceholders_(false), allowNumericKeys_(false) {}
|
{}
|
||||||
|
|
||||||
Features Features::all() { return Features(); }
|
Features Features::all() { return Features(); }
|
||||||
|
|
||||||
Features Features::strictMode() {
|
Features Features::strictMode() {
|
||||||
Features features;
|
Features features;
|
||||||
features.allowComments_ = false;
|
features.allowComments_ = false;
|
||||||
features.strictRoot_ = true;
|
features.strictRoot_ = true;
|
||||||
features.allowDroppedNullPlaceholders_ = false;
|
|
||||||
features.allowNumericKeys_ = false;
|
|
||||||
return features;
|
return features;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,17 +187,7 @@ bool Reader::readValue() {
|
|||||||
currentValue().swapPayload(v);
|
currentValue().swapPayload(v);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case tokenArraySeparator:
|
// Else, fall through...
|
||||||
case tokenObjectEnd:
|
|
||||||
case tokenArrayEnd:
|
|
||||||
if (features_.allowDroppedNullPlaceholders_) {
|
|
||||||
// "Un-read" the current token and mark the current value as a null
|
|
||||||
// token.
|
|
||||||
current_--;
|
|
||||||
Value v;
|
|
||||||
currentValue().swapPayload(v);
|
|
||||||
break;
|
|
||||||
} // Else, fall through...
|
|
||||||
default:
|
default:
|
||||||
return addError("Syntax error: value, object or array expected.", token);
|
return addError("Syntax error: value, object or array expected.", token);
|
||||||
}
|
}
|
||||||
@ -446,11 +433,6 @@ bool Reader::readObject(Token& /*tokenStart*/) {
|
|||||||
if (tokenName.type_ == tokenString) {
|
if (tokenName.type_ == tokenString) {
|
||||||
if (!decodeString(tokenName, name))
|
if (!decodeString(tokenName, name))
|
||||||
return recoverFromError(tokenObjectEnd);
|
return recoverFromError(tokenObjectEnd);
|
||||||
} else if (tokenName.type_ == tokenNumber && features_.allowNumericKeys_) {
|
|
||||||
Value numberName;
|
|
||||||
if (!decodeNumber(tokenName, numberName))
|
|
||||||
return recoverFromError(tokenObjectEnd);
|
|
||||||
name = numberName.asString();
|
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user