moneyphp / money

PHP implementation of Fowler's Money pattern.
http://moneyphp.org
MIT License
4.63k stars 441 forks source link

Money::jsonSerialize() should return currency code instead of Currency instance #547

Closed alle closed 5 years ago

alle commented 5 years ago

Hi, Both Money and Currency classes implement the \JsonSerializable. 👍 When the Money::jsonSerialize() is used in a (string) context, \json_encode returns the proper JSON representations, since to Currency::jsonSerialize() is implicitly called. But if the Money::jsonSerialize() is called alone, it returns an instance of Currency for the currency key, instead of its code.

IMHO opinion, this could be: 'currency' => $this->currency->getCode(),.