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

Missing JsonSerializable interface #129

Open
asgraf opened this issue Sep 15, 2023 · 3 comments
Open

Missing JsonSerializable interface #129

asgraf opened this issue Sep 15, 2023 · 3 comments

Comments

@asgraf
Copy link

asgraf commented Sep 15, 2023

What i did:

$data = [
    'quantity' => Quantity::from(5)
];
debug(json_encode($data));

Expected result:

{
   "quantity": 5
}

Actual result:

{
   "quantity": {}
}
@asgraf asgraf changed the title Missing JsonSerializableInterface Missing JsonSerializable interface Sep 15, 2023
@asgraf
Copy link
Author

asgraf commented Sep 15, 2023

I think this could be easily implemented at level of ExtractableTraits

@mstrouhal
Copy link
Member

Thank you for this feature request, it is very reasonable.
Despite it can not be implemented on level of Extractable traits, as they do not have access to $value property inside object instances, it is possible to implement this feature in a slightly different way.
I am working on it.

@mstrouhal
Copy link
Member

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

2 participants