diff --git a/src/main.rs b/src/main.rs index 9dd7205..b118590 100644 --- a/src/main.rs +++ b/src/main.rs @@ -51,17 +51,19 @@ fn main() { } fn recurse_export(node: &TreeNode, parent_name: &str, out: &mut String) { - if !parent_name.is_empty() && node.r#type.can_have_children() { - writeln!(out, "\"{}\" -> \"{}\";", parent_name, node.print_name()).unwrap(); + if !parent_name.is_empty() && matches!(node.r#type, NodeType::Object { .. }) { + writeln!(out, "\"{}\" -> \"{}\";", parent_name, node.name).unwrap(); } match &node.r#type { NodeType::Array { item } => { - recurse_export(item, &node.print_name(), out); + let mut item = item.clone(); + item.name.push_str(" []"); + recurse_export(&item, parent_name, out); } NodeType::Object { children, .. } => { for child in children { - recurse_export(child, &node.print_name(), out); + recurse_export(child, &node.name, out); } }