Commit 44db1160 authored by Dominik Charousset's avatar Dominik Charousset

Fix minor issues in the JSON reader

(cherry picked from commit d3f665c4)
parent ba1f2c35
...@@ -5,6 +5,12 @@ is based on [Keep a Changelog](https://keepachangelog.com). ...@@ -5,6 +5,12 @@ is based on [Keep a Changelog](https://keepachangelog.com).
## [Unreleased] ## [Unreleased]
### Fixed
- The JSON parser no longer chokes when encountering `null` as last value before
the closing parenthesis.
- The JSON reader now automatically widens integers to doubles as necessary.
## [0.18.6] ## [0.18.6]
### Added ### Added
......
...@@ -128,7 +128,7 @@ void read_json_null_or_nan(string_parser_state& ps, Consumer consumer) { ...@@ -128,7 +128,7 @@ void read_json_null_or_nan(string_parser_state& ps, Consumer consumer) {
transition(done, 'n', res_type = is_nan) transition(done, 'n', res_type = is_nan)
} }
term_state(done) { term_state(done) {
transition(init, " \t\n") transition(done, " \t\n")
} }
fin(); fin();
// clang-format on // clang-format on
......
...@@ -557,6 +557,9 @@ bool json_reader::value(double& x) { ...@@ -557,6 +557,9 @@ bool json_reader::value(double& x) {
if (val.data.index() == detail::json::value::double_index) { if (val.data.index() == detail::json::value::double_index) {
x = std::get<double>(val.data); x = std::get<double>(val.data);
return true; return true;
} else if (val.data.index() == detail::json::value::integer_index) {
x = std::get<int64_t>(val.data);
return true;
} else { } else {
emplace_error(sec::runtime_error, class_name, fn, emplace_error(sec::runtime_error, class_name, fn,
type_clash("json::real", val)); type_clash("json::real", val));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment