Skip to content

Commit b4e300b

Browse files
committed
Merge pull request opencv#9236 from dkurt:fix_json_bool
2 parents 402a77e + 583b327 commit b4e300b

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

modules/core/src/persistence.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3665,7 +3665,6 @@ static char* icvJSONParseValue( CvFileStorage* fs, char* ptr, CvFileNode* node )
36653665
{
36663666
CV_PARSE_ERROR( "Unrecognized value" );
36673667
}
3668-
ptr++;
36693668
}
36703669

36713670
return ptr;

modules/core/test/test_io.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,3 +1318,30 @@ TEST(Core_InputOutput, FileStorage_json_named_nodes)
13181318
ASSERT_EQ(fs["array"].name(), "array");
13191319
fs.release();
13201320
}
1321+
1322+
TEST(Core_InputOutput, FileStorage_json_bool)
1323+
{
1324+
std::string test =
1325+
"{ "
1326+
"\"str_true\": \"true\","
1327+
"\"map_value\": {"
1328+
"\"int_value\": -33333,\n"
1329+
"\"bool_true\": true,"
1330+
"\"str_false\": \"false\","
1331+
"},"
1332+
"\"bool_false\": false, \n"
1333+
"\"array\": [0.1, 0.2]"
1334+
"}";
1335+
FileStorage fs(test, FileStorage::READ | FileStorage::MEMORY);
1336+
1337+
ASSERT_TRUE(fs["str_true"].isString());
1338+
ASSERT_TRUE(fs["map_value"]["bool_true"].isInt());
1339+
ASSERT_TRUE(fs["map_value"]["str_false"].isString());
1340+
ASSERT_TRUE(fs["bool_false"].isInt());
1341+
1342+
ASSERT_EQ((std::string)fs["str_true"], "true");
1343+
ASSERT_EQ((int)fs["map_value"]["bool_true"], 1);
1344+
ASSERT_EQ((std::string)fs["map_value"]["str_false"], "false");
1345+
ASSERT_EQ((int)fs["bool_false"], 0);
1346+
fs.release();
1347+
}

0 commit comments

Comments
 (0)