File tree 4 files changed +19
-14
lines changed 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) {
503
503
Value init (arrayValue);
504
504
currentValue ().swapPayload (init);
505
505
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
- }
513
506
int index = 0 ;
514
507
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
+
515
516
Value& value = currentValue ()[index ++];
516
517
nodes_.push (&value);
517
518
bool ok = readValue ();
@@ -1493,15 +1494,15 @@ bool OurReader::readArray(Token& token) {
1493
1494
Value init (arrayValue);
1494
1495
currentValue ().swapPayload (init);
1495
1496
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
- }
1503
1497
int index = 0 ;
1504
1498
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
+ }
1505
1506
Value& value = currentValue ()[index ++];
1506
1507
nodes_.push (&value);
1507
1508
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