frolovdev / frolovdev/easymoney

Implement toJSON method

Open
#34 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
162
Forks
9
PR merge metrics
No merged PRs in 30d

Description

**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:

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

Example

```js
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

Contributor guide

Open the contributing guide

Research direction

Start by inspecting the existing Money and Currency representations and serialization entry points in @easymoney/money, @easymoney/bignumber.js, and @easymoney/bignumber-money. Confirm whether toJSON should produce the shown JSON string and how object-valued currencies are represented; done means the requested examples serialize consistently across the listed packages.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.