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 @@ -502,15 +502,16 @@ bool Reader::readArray(Token& token) {
502
502
Value init (arrayValue);
503
503
currentValue ().swapPayload (init);
504
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
- }
512
505
int index = 0 ;
513
506
for (;;) {
507
+ skipSpaces ();
508
+ if (current_ != end_ && *current_ == ' ]' && (index == 0 || (features_.allowTrailingCommas_ && !features_.allowDroppedNullPlaceholders_ ))) // empty array or trailing comma
509
+ {
510
+ Token endArray;
511
+ readToken (endArray);
512
+ return true ;
513
+ }
514
+
514
515
Value& value = currentValue ()[index++];
515
516
nodes_.push (&value);
516
517
bool ok = readValue ();
@@ -1477,15 +1478,15 @@ bool OurReader::readArray(Token& token) {
1477
1478
Value init (arrayValue);
1478
1479
currentValue ().swapPayload (init);
1479
1480
currentValue ().setOffsetStart (token.start_ - begin_);
1480
- skipSpaces ();
1481
- if (current_ != end_ && *current_ == ' ]' ) // empty array
1482
- {
1483
- Token endArray;
1484
- readToken (endArray);
1485
- return true ;
1486
- }
1487
1481
int index = 0 ;
1488
1482
for (;;) {
1483
+ skipSpaces ();
1484
+ if (current_ != end_ && *current_ == ' ]' && (index == 0 || (features_.allowTrailingCommas_ && !features_.allowDroppedNullPlaceholders_ ))) // empty array or trailing comma
1485
+ {
1486
+ Token endArray;
1487
+ readToken (endArray);
1488
+ return true ;
1489
+ }
1489
1490
Value& value = currentValue ()[index++];
1490
1491
nodes_.push (&value);
1491
1492
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