File tree Expand file tree Collapse file tree 4 files changed +19
-14
lines changed
Expand file tree Collapse file tree 4 files changed +19
-14
lines changed Original file line number Diff line number Diff line change @@ -503,15 +503,16 @@ bool Reader::readArray(Token& token) {
503503 Value init (arrayValue);
504504 currentValue ().swapPayload (init);
505505 currentValue ().setOffsetStart (token.start_ - begin_);
506- skipSpaces ();
507- if (current_ != end_ && *current_ == ' ]' ) // empty array
508- {
509- Token endArray;
510- readToken (endArray);
511- return true ;
512- }
513506 int index = 0 ;
514507 for (;;) {
508+ skipSpaces ();
509+ if (current_ != end_ && *current_ == ' ]' && (index == 0 || (features_.allowTrailingCommas_ && !features_.allowDroppedNullPlaceholders_ ))) // empty array or trailing comma
510+ {
511+ Token endArray;
512+ readToken (endArray);
513+ return true ;
514+ }
515+
515516 Value& value = currentValue ()[index++];
516517 nodes_.push (&value);
517518 bool ok = readValue ();
@@ -1493,15 +1494,15 @@ bool OurReader::readArray(Token& token) {
14931494 Value init (arrayValue);
14941495 currentValue ().swapPayload (init);
14951496 currentValue ().setOffsetStart (token.start_ - begin_);
1496- skipSpaces ();
1497- if (current_ != end_ && *current_ == ' ]' ) // empty array
1498- {
1499- Token endArray;
1500- readToken (endArray);
1501- return true ;
1502- }
15031497 int index = 0 ;
15041498 for (;;) {
1499+ skipSpaces ();
1500+ if (current_ != end_ && *current_ == ' ]' && (index == 0 || (features_.allowTrailingCommas_ && !features_.allowDroppedNullPlaceholders_ ))) // empty array or trailing comma
1501+ {
1502+ Token endArray;
1503+ readToken (endArray);
1504+ return true ;
1505+ }
15051506 Value& value = currentValue ()[index++];
15061507 nodes_.push (&value);
15071508 bool ok = readValue ();
Original file line number Diff line number Diff line change 1+ [1 ,, ]
Original file line number Diff line number Diff line change 1+ .=[]
2+ .[0]=1
Original file line number Diff line number Diff line change 1+ [1 , ]
You can’t perform that action at this time.
0 commit comments