Skip to content

Commit

Permalink
Re-enable rapidjson::kParseNanAndInfFlag for backwards-compatibility (#…
Browse files Browse the repository at this point in the history
…248)

So the evaluator can continue to read json produced pre-v2.6
The schema validator will continue to test for float infinity and warn
to migrate to string infinity.
  • Loading branch information
nsmith- authored Jul 2, 2024
1 parent 7e07b20 commit d183907
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/correction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -802,14 +802,14 @@ std::unique_ptr<CorrectionSet> CorrectionSet::from_file(const std::string& fn) {
#ifdef WITH_ZLIB
gzFile_s* fpz = gzopen(fn.c_str(), "r");
rapidjson::GzFileReadStream is(fpz, readBuffer, sizeof(readBuffer));
ok = json.ParseStream(is);
ok = json.ParseStream<rapidjson::kParseNanAndInfFlag>(is);
gzclose(fpz);
#else
throw std::runtime_error("Gzip-compressed JSON files are only supported if ZLIB is found when the package is built");
#endif
} else {
rapidjson::FileReadStream is(fp, readBuffer, sizeof(readBuffer));
ok = json.ParseStream(is);
ok = json.ParseStream<rapidjson::kParseNanAndInfFlag>(is);
fclose(fp);
}
if (!ok) {
Expand All @@ -824,7 +824,7 @@ std::unique_ptr<CorrectionSet> CorrectionSet::from_file(const std::string& fn) {

std::unique_ptr<CorrectionSet> CorrectionSet::from_string(const char * data) {
rapidjson::Document json;
rapidjson::ParseResult ok = json.Parse(data);
rapidjson::ParseResult ok = json.Parse<rapidjson::kParseNanAndInfFlag>(data);
if (!ok) {
throw std::runtime_error(
std::string("JSON parse error: ") + rapidjson::GetParseError_En(ok.Code())
Expand Down

0 comments on commit d183907

Please sign in to comment.