Skip to content

[12.x] Adds fromJson() to Collection #55310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

DarkGhostHunter
Copy link
Contributor

What?

Allows a developer to just issue a JSON string and decode it from the Collection class instance throught the fromJson() method. It receives a JSON string and accepts depth and flags parameters to pass down to the json_encode method.

use Illuminate\Support\Collection;

public function something(string $json)
{
    return Collection::fromJson($json);
}

It's left to the developer if the JSON should throw an exception on error (via flag) or not.

@taylorotwell taylorotwell merged commit 267a072 into laravel:12.x Apr 7, 2025
60 checks passed
@DarkGhostHunter DarkGhostHunter deleted the feat/12.x/collection-from-json branch April 7, 2025 14:32
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