Closed gmhafiz closed 1 year ago
I realize there is a PR https://github.com/brick/money/pull/52 which will allow ourselves to implement JsonSerializable
interface.
Let me know if you want to have a built-in jsonSerialize()
or just let the library user to implement this ourselves. If this ever gets implemented, need to let library users to know that it is a breaking change.
Using laravel, it can automatically serialize array or object into json. For example
becomes
However, if laravel is returning brick/money, it returns an empty object:
becomes
How do you make it to serialize into
{"amount":0.1,"currency":"AUD"}
response instead?Other way I can think of is to implement
JsonSerializable
and implementjsonSerialize()
function:As for test:
Also it needed
ext-json
in composer