Skip to content

Commit

Permalink
partially revert 'Added features that allow the reader to accept comm…
Browse files Browse the repository at this point in the history
…on non-standard JSON.'

revert '642befc836ac5093b528e7d8b4fd66b66735a98c',
but keep the *added* methods for `decodedNumber()` and `decodedDouble()`.
  • Loading branch information
cdunn2001 committed Mar 31, 2015
1 parent 6bc7bff commit 65b4714
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 27 deletions.
6 changes: 0 additions & 6 deletions include/json/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ class JSON_API Features {
/// \c true if root must be either an array or an object value. Default: \c
/// false.
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
Expand Down
24 changes: 3 additions & 21 deletions src/lib_json/json_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,14 @@ typedef std::auto_ptr<CharReader> CharReaderPtr;
// ////////////////////////////////

Features::Features()
: allowComments_(true), strictRoot_(false),
allowDroppedNullPlaceholders_(false), allowNumericKeys_(false) {}

: allowComments_(true), strictRoot_(false)
{}
Features Features::all() { return Features(); }

Features Features::strictMode() {
Features features;
features.allowComments_ = false;
features.strictRoot_ = true;
features.allowDroppedNullPlaceholders_ = false;
features.allowNumericKeys_ = false;
return features;
}

Expand Down Expand Up @@ -190,17 +187,7 @@ bool Reader::readValue() {
currentValue().swapPayload(v);
}
break;
case tokenArraySeparator:
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...
// Else, fall through...
default:
return addError("Syntax error: value, object or array expected.", token);
}
Expand Down Expand Up @@ -446,11 +433,6 @@ bool Reader::readObject(Token& /*tokenStart*/) {
if (tokenName.type_ == tokenString) {
if (!decodeString(tokenName, name))
return recoverFromError(tokenObjectEnd);
} else if (tokenName.type_ == tokenNumber && features_.allowNumericKeys_) {
Value numberName;
if (!decodeNumber(tokenName, numberName))
return recoverFromError(tokenObjectEnd);
name = numberName.asString();
} else {
break;
}
Expand Down

0 comments on commit 65b4714

Please sign in to comment.