Skip to main content

Module types

Module types 

Source
Expand description

Runtime type guards and JSON path utilities.

This module provides type checking and dot-path access for JSON values, inspired by AdonisJS @adonisjs/core/helpers.

Requires the json feature flag.

§Example

use rok_utils::types::{is_string, is_number, get_path};
use serde_json::json;

let value = json!({"Name": "Alice", "age": 30});

assert!(is_string(&value["Name"]));
assert!(is_number(&value["age"]));

let data = json!({"user": {"address": {"city": "NYC"}}});
let city = get_path(&data, "user.address.city");
assert_eq!(city, Some(&json!("NYC")));

Functions§

deep_equal
get_path
is_array
is_bool
is_defined
is_null
is_number
is_object
is_string
set_path