diff --git a/src/JsonPointer.php b/src/JsonPointer.php index 0b950a4..1311ad3 100644 --- a/src/JsonPointer.php +++ b/src/JsonPointer.php @@ -289,6 +289,7 @@ public static function remove(&$holder, $pathItems, $flags = 0) $isAssociative = true; break; } + $i++; } } diff --git a/tests/src/JsonPointerTest.php b/tests/src/JsonPointerTest.php index bf025c3..2770cd3 100644 --- a/tests/src/JsonPointerTest.php +++ b/tests/src/JsonPointerTest.php @@ -96,6 +96,13 @@ public function testGetSetDeleteObject() $this->assertEquals(null, $s->one->two); } + public function testSequentialArrayIsPreserved() + { + $json = [ 'l1' => [ 0 => 'foo', 1 => 'bar', 2 => 'baz' ] ]; + JsonPointer::remove($json, ['l1', '1'], JsonPointer::TOLERATE_ASSOCIATIVE_ARRAYS); + $this->assertSame('{"l1":["foo","baz"]}', json_encode($json)); + } + } class Sample