From ab7f9afe9ca3d60b14210b97601314dfafbe462c Mon Sep 17 00:00:00 2001 From: MonkeybreadSoftware Date: Fri, 2 Aug 2024 12:33:56 +0100 Subject: [PATCH] Added bool and null for as_double() The code doing JSON diffs can't compare as it would run the "not a double" exception, if one side has a number and other a null value. So we fix this by returning 0 here for double value. --- include/jsoncons/basic_json.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/jsoncons/basic_json.hpp b/include/jsoncons/basic_json.hpp index 937583539..40e353a40 100644 --- a/include/jsoncons/basic_json.hpp +++ b/include/jsoncons/basic_json.hpp @@ -4369,6 +4369,10 @@ namespace jsoncons { return static_cast(cast().value()); case json_storage_kind::json_const_pointer: return cast().value()->as_double(); + case json_storage_kind::null_value: + return 0; + case json_storage_kind::bool_value: + return cast().value(); default: JSONCONS_THROW(json_runtime_error("Not a double")); }