Expand description
JSON number types expressible in a JSONPath query.
Exposes the JsonInt
and JsonUInt
types
that can represent any numbers in the range [-253+1, 253-1],
with the unsigned version additionally guaranteed to be non-negative. All operations
implemented are automatically checked for over- and underflow.
This is governed by the I-JSON IETF specification. All numbers appearing in a JSONPath query are required to be I-JSON conformant (see RFC 2.1-4.1). This includes index values, all values in slice selectors, and constants in filter comparison expressions.
§Examples
// An i32/u32 converts directly to JsonInt/JsonUInt.
let a = JsonInt::from(-42);
let b = JsonUInt::from(42);
// i64/u64 has to be checked for overflow.
let c = JsonInt::try_from(42_000_000_000_000_i64).expect("within range");
let d = JsonInt::try_from(42_000_000_000_000_000_i64).expect_err("too large");
assert_eq!(a.as_i64(), -42);
assert_eq!(b.as_u64(), 42);
assert_eq!(c.as_i64(), 42_000_000_000_000_i64);
Modules§
Structs§
- Json
Float - IEEE 754 conformant floating-point number expressible in JSON.
- JsonInt
- Signed interoperable JSON integer.
- Json
NonZeroU Int - Unsigned interoperable JSON integer known to be non-zero.
- JsonU
Int - Unsigned interoperable JSON integer.
Enums§
- Json
Number - JSONPath numeric type - either a
JsonInt
or aJsonFloat
.