Skip to content

Commit

Permalink
Do not escape slashes or unicode
Browse files Browse the repository at this point in the history
  • Loading branch information
akalongman committed Nov 5, 2023
1 parent c69eb16 commit b661ace
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Lodash/Http/Resources/JsonResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
use function method_exists;
use function ucfirst;

use const JSON_UNESCAPED_SLASHES;
use const JSON_UNESCAPED_UNICODE;

abstract class JsonResource extends BaseResource
{
use TransformsData;
Expand Down Expand Up @@ -185,4 +188,9 @@ private static function undot(array $array): array

return $result;
}

public function jsonOptions(): int
{
return JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
}
}
8 changes: 8 additions & 0 deletions src/Lodash/Http/Resources/JsonResourceCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
use function array_merge_recursive;
use function is_null;

use const JSON_UNESCAPED_SLASHES;
use const JSON_UNESCAPED_UNICODE;

class JsonResourceCollection extends BaseResourceCollection
{
public function toArray($request): array
Expand Down Expand Up @@ -49,4 +52,9 @@ protected function preparePaginatedResponse($request)

return (new PaginatedResourceResponse($this))->toResponse($request);
}

public function jsonOptions(): int
{
return JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
}
}

0 comments on commit b661ace

Please sign in to comment.