Skip to content

Commit 2c83ac0

Browse files
Initialize json value to nullptr in constructor and handle null case in switch statement
1 parent abe237e commit 2c83ac0

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

include/json.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ namespace json
4747
switch (type)
4848
{
4949
case json_type::null:
50+
value = nullptr;
5051
break;
5152
case json_type::boolean:
5253
value = false;

src/json.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace json
66
{
7-
json::json(std::initializer_list<json> init)
7+
json::json(std::initializer_list<json> init) : value(nullptr)
88
{
99
if (init.size() == 2 && init.begin()->is_string())
1010
{ // we have a key-value pair..

0 commit comments

Comments
 (0)