From 50069d72da3c34b60d287c9c8777c67ec960c244 Mon Sep 17 00:00:00 2001 From: Christopher Dunn Date: Sun, 8 Mar 2015 13:35:57 -0500 Subject: [PATCH] prefer std::string for setComment() in case of embedded nulls --- include/json/value.h | 1 + src/test_lib_json/main.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/json/value.h b/include/json/value.h index d91ccc4..26bb38b 100644 --- a/include/json/value.h +++ b/include/json/value.h @@ -512,6 +512,7 @@ Json::Value obj_value(Json::objectValue); // {} //# endif /// \deprecated Always pass len. + JSONCPP_DEPRECATED("Use setComment(std::string const&) instead.") void setComment(const char* comment, CommentPlacement placement); /// Comments must be //... or /* ... */ void setComment(const char* comment, size_t len, CommentPlacement placement); diff --git a/src/test_lib_json/main.cpp b/src/test_lib_json/main.cpp index 71e9491..f0e3436 100644 --- a/src/test_lib_json/main.cpp +++ b/src/test_lib_json/main.cpp @@ -1542,7 +1542,7 @@ JSONTEST_FIXTURE(ValueTest, StaticString) { JSONTEST_FIXTURE(ValueTest, CommentBefore) { Json::Value val; // fill val - val.setComment("// this comment should appear before", Json::commentBefore); + val.setComment(std::string("// this comment should appear before"), Json::commentBefore); Json::StreamWriterBuilder wbuilder; wbuilder.settings_["commentStyle"] = "All"; {