Skip to content

Commit 50069d7

Browse files
committed
prefer std::string for setComment()
in case of embedded nulls
1 parent 24682e3 commit 50069d7

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

include/json/value.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ Json::Value obj_value(Json::objectValue); // {}
512512
//# endif
513513

514514
/// \deprecated Always pass len.
515+
JSONCPP_DEPRECATED("Use setComment(std::string const&) instead.")
515516
void setComment(const char* comment, CommentPlacement placement);
516517
/// Comments must be //... or /* ... */
517518
void setComment(const char* comment, size_t len, CommentPlacement placement);

src/test_lib_json/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,7 @@ JSONTEST_FIXTURE(ValueTest, StaticString) {
15421542

15431543
JSONTEST_FIXTURE(ValueTest, CommentBefore) {
15441544
Json::Value val; // fill val
1545-
val.setComment("// this comment should appear before", Json::commentBefore);
1545+
val.setComment(std::string("// this comment should appear before"), Json::commentBefore);
15461546
Json::StreamWriterBuilder wbuilder;
15471547
wbuilder.settings_["commentStyle"] = "All";
15481548
{

0 commit comments

Comments
 (0)