Coder-Spirit / php-bignumbers

A robust library to handle immutable big numbers inside PHP applications
MIT License
131 stars 29 forks source link

Implemented JsonSerializable #75

Open Zakini opened 4 years ago

Zakini commented 4 years ago

This allows Decimal objects to be JSON serialized using json_encode(). They are serialized as their internal string representation since this is the most accurate.

Using json_encode($decimal, JSON_NUMERIC_CHECK) results in the decimal value being serialized as a JSON number, which might be desirable for some users. This might be worth documenting, though I'm not sure where would be best to put that.