use computeruse::Desktop;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("UIElement Serialization Example");
println!("================================");
let desktop = Desktop::new(false, false)?;
let root = desktop.root();
let json = serde_json::to_string_pretty(&root)?;
println!("Serialized root element:");
println!("{json}");
if let Ok(children) = root.children() {
if !children.is_empty() {
println!("\nSerializing first child element:");
let first_child_json = serde_json::to_string_pretty(&children[0])?;
println!("{first_child_json}");
}
}
let compact_json = serde_json::to_string(&root)?;
println!("\nCompact JSON format:");
println!("{compact_json}");
if let Ok(children) = root.children() {
let children_json = serde_json::to_string_pretty(&children)?;
println!("\nSerialized children collection:");
println!("{children_json}");
}
Ok(())
}