File tree Expand file tree Collapse file tree 1 file changed +19
-19
lines changed Expand file tree Collapse file tree 1 file changed +19
-19
lines changed Original file line number Diff line number Diff line change @@ -495,6 +495,25 @@ impl Value {
495
495
}
496
496
}
497
497
498
+ /// Returns true if the `Value` is a Number. Returns false otherwise.
499
+ ///
500
+ /// ```
501
+ /// # use serde_json::json;
502
+ /// #
503
+ /// let v = json!({ "a": 1, "b": "2" });
504
+ ///
505
+ /// assert!(v["a"].is_number());
506
+ ///
507
+ /// // The string `"2"` is a string, not a number.
508
+ /// assert!(!v["b"].is_number());
509
+ /// ```
510
+ pub fn is_number ( & self ) -> bool {
511
+ match * self {
512
+ Value :: Number ( _) => true ,
513
+ _ => false ,
514
+ }
515
+ }
516
+
498
517
/// If the `Value` is an Number, returns the associated [`Number`]. Returns
499
518
/// None otherwise.
500
519
///
@@ -517,25 +536,6 @@ impl Value {
517
536
}
518
537
}
519
538
520
- /// Returns true if the `Value` is a Number. Returns false otherwise.
521
- ///
522
- /// ```
523
- /// # use serde_json::json;
524
- /// #
525
- /// let v = json!({ "a": 1, "b": "2" });
526
- ///
527
- /// assert!(v["a"].is_number());
528
- ///
529
- /// // The string `"2"` is a string, not a number.
530
- /// assert!(!v["b"].is_number());
531
- /// ```
532
- pub fn is_number ( & self ) -> bool {
533
- match * self {
534
- Value :: Number ( _) => true ,
535
- _ => false ,
536
- }
537
- }
538
-
539
539
/// Returns true if the `Value` is an integer between `i64::MIN` and
540
540
/// `i64::MAX`.
541
541
///
You can’t perform that action at this time.
0 commit comments