Skip to content

Commit 79b34ce

Browse files
committed
Fixed extra / and XSD::type based on float and int
1 parent 07fef50 commit 79b34ce

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

src/lib.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,21 @@ fn process_value(
162162
));
163163
}
164164
Value::Number(num) => {
165-
let literal = if let Some(int) = num.as_i64() {
166-
int.to_string()
167-
} else if let Some(float) = num.as_f64() {
168-
float.to_string()
165+
if num.as_i64().is_some() {
166+
graph.insert(TripleRef::new(
167+
subject_stack.back().unwrap(),
168+
NamedNodeRef::new(prop.as_str()).unwrap(),
169+
&Literal::new_typed_literal(num.to_string(), xsd::INT),
170+
));
171+
} else if num.as_f64().is_some() {
172+
graph.insert(TripleRef::new(
173+
subject_stack.back().unwrap(),
174+
NamedNodeRef::new(prop.as_str()).unwrap(),
175+
&Literal::new_typed_literal(num.to_string(), xsd::FLOAT),
176+
));
169177
} else {
170178
return;
171-
};
172-
graph.insert(TripleRef::new(
173-
subject_stack.back().unwrap(),
174-
NamedNodeRef::new(prop.as_str()).unwrap(),
175-
&Literal::new_typed_literal(literal, xsd::INT),
176-
));
179+
}
177180
}
178181
Value::String(s) => {
179182
graph.insert(TripleRef::new(
@@ -197,7 +200,7 @@ fn process_value(
197200

198201
for (key, val) in obj {
199202
let nested_property: Option<String> =
200-
Some(format!("{}/{}/", namespace, key));
203+
Some(format!("{}/{}", namespace, key));
201204
process_value(subject_stack, &nested_property, val, graph, namespace);
202205
}
203206
subject_stack.pop_back();

0 commit comments

Comments
 (0)