File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -279,6 +279,25 @@ impl Number {
279
279
}
280
280
}
281
281
282
+ #[ cfg( feature = "arbitrary_precision" ) ]
283
+ /// Returns the `&str` representation of the `Number`.
284
+ /// ```
285
+ /// # use serde_json::Number;
286
+ /// for value in [
287
+ /// "7",
288
+ /// "12.34",
289
+ /// "34e-56789",
290
+ /// "0.0123456789000000012345678900000001234567890000123456789",
291
+ /// "343412345678910111213141516171819202122232425262728293034",
292
+ /// "-343412345678910111213141516171819202122232425262728293031",
293
+ /// ] {
294
+ /// let number: Number = serde_json::from_str(value).unwrap();
295
+ /// assert_eq!(number.as_str(), value);
296
+ /// }
297
+ pub fn as_str ( & self ) -> & str {
298
+ & self . n
299
+ }
300
+
282
301
pub ( crate ) fn as_f32 ( & self ) -> Option < f32 > {
283
302
#[ cfg( not( feature = "arbitrary_precision" ) ) ]
284
303
match self . n {
You can’t perform that action at this time.
0 commit comments