ENH: Format `decimal.Decimal` as full precision strings in `.to_json(...)`
Encodes `decimal.Decimal` as full precision strings in `.to_json(...)`. The old behaviour is to convert `decimal.Decimal` to floats potentially loosing precision.

- [ ] closes #xxxx (Replace xxxx with the GitHub issue number)
- [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature
- [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).
- [x] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions.
- [x] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.

> Thanks for working on this

Thanks for taking your time to review this. I'm planing to open an issue discussing if this should be hidden behind a flag, such that the default behaviour remains unchanged. This draft is just a proof of concept.

The decimal module has no C API, unfortunately. I found a recent issue in the cpython repo discussing an implementation but it hasn't happened yet. As far as I recall the maintainers of cpython thought this would bloat the C API without any real gain.

I do agree on your comments and will update the patch. It should be noted that most of the implementation is copy/pasted from here. Maybe this has some bugs as-well?
https://github.com/pandas-dev/pandas/blob/7415aca37159a99f8f99d93a1908070ddf36178c/pandas/_libs/src/vendored/ujson/python/objToJSON.c#L352-L374 > It should be noted that most of the implementation is copy/pasted from here. Maybe this has some bugs as-well?

That's certainly possible. Ironically I am probably also the one responsible for that. Without looking at the blame...I'll just say the less I know, the better.

Fixing that is out of scope for this PR, but I would prefer to not copy/paste those issues over. Thanks! @Tolker-KU generally this looks pretty good. Can you add a whatsnew note to our 3.0 release for this? @mroeschke mind taking a look? Thanks @Tolker-KU 