Base Unit class implements JsonSerializable now #23
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm using this library in a Laravel project where I cast various values to units to be able to easily convert them. The admin area is built with Filament/Livewire. Livewire validates the current request data by creating a JSON fingerprint from it. Somehow a unit is occasionally encoded as
{}
or as[]
in this fingerprint, causing a mismatch and an error. My changes fixes this.My particular use case here sounds a bit weird tbh, but being able to encode a unit as JSON could be quite useful in other areas, like API responses for example. Anyways, I'd appreciate it if you could merge these changes. Cheers!