File tree 2 files changed +8
-22
lines changed 2 files changed +8
-22
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,6 @@ class JSON_API Features {
23
23
/* * \brief A configuration that allows all features and assumes all strings
24
24
* are UTF-8.
25
25
* - C & C++ comments are allowed
26
- * - Trailing commas in objects and arrays are allowed.
27
26
* - Root object can be any JSON value
28
27
* - Assumes Value strings are encoded in UTF-8
29
28
*/
@@ -32,7 +31,6 @@ class JSON_API Features {
32
31
/* * \brief A configuration that is strictly compatible with the JSON
33
32
* specification.
34
33
* - Comments are forbidden.
35
- * - Trailing commas in objects and arrays are forbidden.
36
34
* - Root object must be either an array or an object value.
37
35
* - Assumes Value strings are encoded in UTF-8
38
36
*/
@@ -45,10 +43,6 @@ class JSON_API Features {
45
43
// / \c true if comments are allowed. Default: \c true.
46
44
bool allowComments_{true };
47
45
48
- // / \c true if trailing commas in objects and arrays are allowed. Default \c
49
- // / true.
50
- bool allowTrailingCommas_{true };
51
-
52
46
// / \c true if root must be either an array or an object value. Default: \c
53
47
// / false.
54
48
bool strictRoot_{false };
Original file line number Diff line number Diff line change @@ -67,7 +67,6 @@ Features Features::all() { return {}; }
67
67
Features Features::strictMode () {
68
68
Features features;
69
69
features.allowComments_ = false ;
70
- features.allowTrailingCommas_ = false ;
71
70
features.strictRoot_ = true ;
72
71
features.allowDroppedNullPlaceholders_ = false ;
73
72
features.allowNumericKeys_ = false ;
@@ -455,9 +454,7 @@ bool Reader::readObject(Token& token) {
455
454
initialTokenOk = readToken (tokenName);
456
455
if (!initialTokenOk)
457
456
break ;
458
- if (tokenName.type_ == tokenObjectEnd &&
459
- (name.empty () ||
460
- features_.allowTrailingCommas_ )) // empty object or trailing comma
457
+ if (tokenName.type_ == tokenObjectEnd && name.empty ()) // empty object
461
458
return true ;
462
459
name.clear ();
463
460
if (tokenName.type_ == tokenString) {
@@ -505,20 +502,15 @@ bool Reader::readArray(Token& token) {
505
502
Value init (arrayValue);
506
503
currentValue ().swapPayload (init);
507
504
currentValue ().setOffsetStart (token.start_ - begin_);
505
+ skipSpaces ();
506
+ if (current_ != end_ && *current_ == ' ]' ) // empty array
507
+ {
508
+ Token endArray;
509
+ readToken (endArray);
510
+ return true ;
511
+ }
508
512
int index = 0 ;
509
513
for (;;) {
510
- skipSpaces ();
511
- if (current_ != end_ && *current_ == ' ]' &&
512
- (index == 0 ||
513
- (features_.allowTrailingCommas_ &&
514
- !features_.allowDroppedNullPlaceholders_ ))) // empty array or trailing
515
- // comma
516
- {
517
- Token endArray;
518
- readToken (endArray);
519
- return true ;
520
- }
521
-
522
514
Value& value = currentValue ()[index ++];
523
515
nodes_.push (&value);
524
516
bool ok = readValue ();
You can’t perform that action at this time.
0 commit comments