Skip to main content

resolve_path_string

Function resolve_path_string 

Source
pub fn resolve_path_string(data: &Value, path: &str) -> Option<String>
Expand description

Resolves a path and converts the result to a string representation.

For String values, returns the string directly. For numbers and booleans, uses to_string(). For null, returns None. For objects and arrays, returns their JSON serialization.

ยงExamples

use ferro_json_ui::resolve_path_string;
use serde_json::json;

let data = json!({"count": 42, "name": "Alice"});
assert_eq!(resolve_path_string(&data, "/name"), Some("Alice".to_string()));
assert_eq!(resolve_path_string(&data, "/count"), Some("42".to_string()));