1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use crate::{
api::PROPERTIES,
error::{ZomeApiError, ZomeApiResult},
};
use holochain_json_api::json::JsonString;
use serde_json::Value;
pub fn property<S: Into<String>>(name: S) -> ZomeApiResult<JsonString> {
let properties: Value = serde_json::from_str(&PROPERTIES.to_string()).map_err(|_| {
ZomeApiError::from("DNA Properties could not be parsed as JSON".to_string())
})?;
properties
.get(name.into())
.map(|value| JsonString::from(value.clone()))
.ok_or_else(|| ZomeApiError::from("field does not exist in DNA properties".to_string()))
}