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(),.
Hi, Both
Money
andCurrency
classes implement the\JsonSerializable
. 👍 When theMoney::jsonSerialize()
is used in a(string)
context,\json_encode
returns the proper JSON representations, since toCurrency::jsonSerialize()
is implicitly called. But if theMoney::jsonSerialize()
is called alone, it returns an instance ofCurrency
for thecurrency
key, instead of itscode
.IMHO opinion, this could be:
'currency' => $this->currency->getCode(),
.