diff --git a/.gitignore b/.gitignore index ea8c4bf..eed3cc5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +*.txt diff --git a/src/lib.rs b/src/lib.rs index ecae84c..63c3dfc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -155,6 +155,12 @@ fn process_value( graph: &mut Graph, namespace: &String, ) { + let ns = if namespace.ends_with("/") { + namespace + } else { + &([namespace, "/"].join("")) + }; + if let Some(last_subject) = subject_stack.clone().back() { if let Some(prop) = property { match value { @@ -203,15 +209,14 @@ fn process_value( )); for (key, val) in obj { - let nested_property: Option = - Some(format!("{}/{}", namespace, key)); - process_value(subject_stack, &nested_property, val, graph, namespace); + let nested_property: Option = Some(format!("{}{}", ns, key)); + process_value(subject_stack, &nested_property, val, graph, ns); } subject_stack.pop_back(); } Value::Array(arr) => { for val in arr { - process_value(subject_stack, property, val, graph, namespace); + process_value(subject_stack, property, val, graph, ns); } } }