Skip to content

File::json() method to get json decoded data from a file.#46481

Merged
taylorotwell merged 2 commits into
laravel:10.xfrom
AustinW:10.x
Mar 16, 2023
Merged

File::json() method to get json decoded data from a file.#46481
taylorotwell merged 2 commits into
laravel:10.xfrom
AustinW:10.x

Conversation

@AustinW

@AustinW AustinW commented Mar 15, 2023

Copy link
Copy Markdown
Contributor

This adds a convenient File::json() method to retrieve json encoded data from a file.

Example of current flow:

$contents = File::get('sample.json');
$data = json_decode($contents, true);

New flow using File::json:

$data = File::json('sample.json');

This additional method will not affect current users and eases the development flow when accessing json files. Tests are included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants