pub fn path_key(key: &str) -> Cow<'_, str>Expand description
A key as a path writes it: as it is, or as a JSON string in brackets
(["k8s.io/name"]) when it is empty, has whitespace at either end, or
holds ., [, ], ", \ or a control character. See the
module docs.
use rich_data::profile::path_key;
assert_eq!(path_key("user"), "user");
assert_eq!(path_key("first name"), "first name");
assert_eq!(path_key("k8s.io/name"), r#"["k8s.io/name"]"#);
assert_eq!(path_key(""), r#"[""]"#);