Skip to content

Commit

Permalink
Merge pull request #76 from kapow/force-objects-to-arrays
Browse files Browse the repository at this point in the history
Handle multi-level JSON with objects and arrays
  • Loading branch information
SoftCreatR authored Feb 10, 2023
2 parents cf57613 + b1f25ac commit 3028241
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/AccessHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public static function unsetValue(mixed &$collection, $key): void
/**
* @throws JSONPathException
*/
public static function arrayValues(array|ArrayAccess $collection): array|ArrayAccess
public static function arrayValues(array|object $collection): array|ArrayAccess
{
if (\is_array($collection)) {
return \array_values($collection);
Expand Down
4 changes: 2 additions & 2 deletions src/Filters/RecursiveFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public function filter($collection): array
/**
* @throws JSONPathException
*/
private function recurse(array &$result, array|ArrayAccess $data): void
private function recurse(array &$result, array|object $data): void
{
$result[] = $data;
$result[] = (array)$data;

if (AccessHelper::isCollectionType($data)) {
foreach (AccessHelper::arrayValues($data) as $value) {
Expand Down

0 comments on commit 3028241

Please sign in to comment.