Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/json/writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ String JSON_API valueToString(
PrecisionType precisionType = PrecisionType::significantDigits);
String JSON_API valueToString(bool value);
String JSON_API valueToQuotedString(const char* value);
String JSON_API valueToQuotedString(const char* value, size_t length);

/// \brief Output using the StyledStreamWriter.
/// \see Json::operator>>()
Expand Down
8 changes: 6 additions & 2 deletions src/lib_json/json_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,10 @@ String valueToQuotedString(const char* value) {
return valueToQuotedStringN(value, strlen(value));
}

String valueToQuotedString(const char* value, size_t length) {
return valueToQuotedStringN(value, length);
}

// Class Writer
// //////////////////////////////////////////////////////////////////
Writer::~Writer() = default;
Expand Down Expand Up @@ -491,7 +495,7 @@ void StyledWriter::writeValue(const Value& value) {
const String& name = *it;
const Value& childValue = value[name];
writeCommentBeforeValue(childValue);
writeWithIndent(valueToQuotedString(name.c_str()));
writeWithIndent(valueToQuotedString(name.c_str(), name.size()));
document_ += " : ";
writeValue(childValue);
if (++it == members.end()) {
Expand Down Expand Up @@ -709,7 +713,7 @@ void StyledStreamWriter::writeValue(const Value& value) {
const String& name = *it;
const Value& childValue = value[name];
writeCommentBeforeValue(childValue);
writeWithIndent(valueToQuotedString(name.c_str()));
writeWithIndent(valueToQuotedString(name.c_str(), name.size()));
*document_ << " : ";
writeValue(childValue);
if (++it == members.end()) {
Expand Down
Loading