Skip to content

Implement toJSON method #34

@frolovdev

Description

@frolovdev

Is your feature request related to a problem? Please describe.
Any web application operates with JSON, many API often both receive JSON and send in a monetary format.

Describe the solution you'd like
We need to add the toJson method, which returns something like:

"{"amount":5,"currency":"USD"}"

Example

createMoney({ amount: 5, currency: "USD" }).toJSON()
// => "{"amount":5,"currency":"USD"}"

Don't forget that Currency can be also an Object type, it's also need serialization method.

Packages:

  • @easymoney/money
  • @easymoney/bignumber.js
  • @easymoney/bignumber-money

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions