Skip to content

Add BigDecimal <-> serde_json::Value conversions under serde-json feature #157

@lovasoa

Description

@lovasoa

Hi,

It would be useful to support direct conversions between BigDecimal and serde_json::Value when the serde-json feature is enabled.

Currently, we can serialize/deserialize via Serde, but not convert directly without manual handling. Proposed additions:

  • impl From<BigDecimal> for Value

    • Use Value::Number when representable; otherwise fallback to Value::String.
  • impl TryFrom for BigDecimal`

    • store Numbers directly and parse Strings

Both gated under #[cfg(feature = "serde-json")].

This would remove boilerplate and probably improve performance compared to custom implementations by the user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions