Repository: serde-rs/json (language: rust)

Issue:
It would be great if `Number` had an `as_str` method if `"arbitrary_precision"` is enabled.
Would you be open to a pull request that added an `as_str` method to `Number` if `"arbitrary_precision"` is enabled?


Discussion / hints:
I agree &mdash; seems good to me. Please send a PR.
Great, on the way!

By the way, thanks for the awesome work... on all of your crates.

Fix patch:
diff --git a/src/number.rs b/src/number.rs
index 7ff66681d..f4925a0b4 100644
--- a/src/number.rs
+++ b/src/number.rs
@@ -279,6 +279,25 @@ impl Number {
         }
     }
 
+    #[cfg(feature = "arbitrary_precision")]
+    /// Returns the `&str` representation of the `Number`.
+    /// ```
+    /// # use serde_json::Number;
+    /// for value in [
+    ///     "7",
+    ///     "12.34",
+    ///     "34e-56789",
+    ///     "0.0123456789000000012345678900000001234567890000123456789",
+    ///     "343412345678910111213141516171819202122232425262728293034",
+    ///     "-343412345678910111213141516171819202122232425262728293031",
+    /// ] {
+    ///     let number: Number = serde_json::from_str(value).unwrap();
+    ///     assert_eq!(number.as_str(), value);
+    /// }
+    pub fn as_str(&self) -> &str {
+        &self.n
+    }
+
     pub(crate) fn as_f32(&self) -> Option<f32> {
         #[cfg(not(feature = "arbitrary_precision"))]
         match self.n {


Test patch: