brick / money

A money and currency library for PHP
MIT License
1.61k stars 96 forks source link

`Currency` should be JSON serializable #79

Closed joelvh closed 9 months ago

joelvh commented 10 months ago

We regularly pass the currency along to an API as part of an array and expected Currency to serialize to a JSON string because it's stringable. However, it serializes to an empty array.

v0.7.0 made AbstractMoney JSON serializable, but Currency wasn't treated that way.

This updates Currency to be JSON serializable when using it separately from Money.

BenMorel commented 10 months ago

Makes sense! Please add a test and I'll merge it :+1:

joelvh commented 10 months ago

@BenMorel added a test - let me know if you had others in mind. (Existing Money tests validate the JSON serialization is correct too.)

BenMorel commented 9 months ago

Thank you, released as 0.8.1!