Skip to content
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

JSON serialization support would be nice #22

Open
judgej opened this issue Jul 2, 2015 · 0 comments
Open

JSON serialization support would be nice #22

judgej opened this issue Jul 2, 2015 · 0 comments

Comments

@judgej
Copy link

judgej commented Jul 2, 2015

Was trying to convert a Sequence object to JSON, and just getting {} as the result. However, serializing $sequence->all() works just fine - gives me an array of items. Obviously the items themselves need to be serializable too, but that's not php-collection's problem.

So, could Sequence (and I guess the other collection types) be given JSON serialisation support? It is probably just as simple as adding this method and implementing \JsonSerializable:

    public function jsonSerialize() {
        return $this->all();
    }

I can provide a PR if this is something you would like.

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

No branches or pull requests

1 participant