MCPcopy Create free account
hub / github.com/PowerShell/DSC / load_value_from_json

Function load_value_from_json

lib/dsc-lib/src/util.rs:162–181  ·  view source on GitHub ↗
(path: &PathBuf, value_name: &str)

Source from the content-addressed store, hash-verified

160}
161
162fn load_value_from_json(path: &PathBuf, value_name: &str) -> Result<serde_json::Value, DscError> {
163 let file = File::open(path)?;
164 let reader = BufReader::new(file);
165 let root: serde_json::Value = match serde_json::from_reader(reader) {
166 Ok(j) => j,
167 Err(err) => {
168 return Err(DscError::Json(err));
169 }
170 };
171
172 if let Some(r) = root.as_object() {
173 for (key, value) in r {
174 if *key == value_name {
175 return Ok(value.clone())
176 }
177 }
178 }
179
180 Err(DscError::NotSupported(value_name.to_string()))
181}
182
183/// Gets path to the current dsc process.
184/// If dsc is started using a symlink, this functon returns target of the symlink.

Callers 1

get_settingFunction · 0.85

Calls 2

JsonClass · 0.85
newFunction · 0.50

Tested by

no test coverage detected