Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
use serde_json::Value;
/// Extract command, args, and environment from JSON config
pub fn extract_command_args(
config: &Value,
) -> Option<(String, Vec<Value>, serde_json::Map<String, Value>)> {
let obj = config.as_object()?;
let command = obj.get("command")?.as_str()?.to_string();
let args = obj.get("args")?.as_array()?.clone();
let envs = obj
.get("env")
.unwrap_or(&Value::Object(serde_json::Map::new()))
.as_object()?
.clone();
Some((command, args, envs))
}
/// Extract boolean "active" field from JSON config
pub fn extract_active_status(config: &Value) -> Option<bool> {
let obj = config.as_object()?;
let active = obj.get("active")?.as_bool()?;
Some(active)
}