Skip to content

Commit 29501c4

Browse files
committed
clarify comments
And throw instead of return null for invalid settings.
1 parent 7796f20 commit 29501c4

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

include/json/reader.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,17 @@ class JSON_API CharReaderBuilder : public CharReader::Factory {
299299
These are case-sensitive.
300300
Available settings (case-sensitive):
301301
- "collectComments": false or true
302-
- "allowComments"
303-
- "strictRoot"
304-
- "allowDroppedNullPlaceholders"
305-
- "allowNumericKeys"
302+
- true to collect comment and allow writing them
303+
back during serialization, false to discard comments.
304+
This parameter is ignored if allowComments is false.
305+
- "allowComments": false or true
306+
- true if comments are allowed.
307+
- "strictRoot": false or true
308+
- true if root must be either an array or an object value
309+
- "allowDroppedNullPlaceholders": false or true
310+
- true if dropped null placeholders are allowed. (See StreamWriterBuilder.)
311+
- "allowNumericKeys": false or true
312+
- true if numeric object keys are allowed.
306313
307314
You can examine 'settings_` yourself
308315
to see the defaults. You can also write and read them just like any

include/json/writer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ class JSON_API StreamWriterBuilder : public StreamWriter::Factory {
9292
Available settings (case-sensitive):
9393
- "commentStyle": "None" or "All"
9494
- "indentation": "<anything>"
95-
- "enableYAMLCompatibility": False or True
95+
- "enableYAMLCompatibility": false or true
9696
- slightly change the whitespace around colons
97-
- "dropNullPlaceholders": False or True
97+
- "dropNullPlaceholders": false or true
9898
- Drop the "null" string from the writer's output for nullValues.
9999
Strictly speaking, this is not valid JSON. But when the output is being
100100
fed to a browser's Javascript, it makes for smaller output and the

src/lib_json/json_writer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ StreamWriter* StreamWriterBuilder::newStreamWriter() const
981981
} else if (cs_str == "None") {
982982
cs = CommentStyle::None;
983983
} else {
984-
return NULL;
984+
throw std::runtime_error("commentStyle must be 'All' or 'None'");
985985
}
986986
std::string colonSymbol = " : ";
987987
if (eyc) {

0 commit comments

Comments
 (0)