Skip to content

Commit a00884d

Browse files
committed
Created oxrdf::graph containing triples from JSON file
1 parent 19710e2 commit a00884d

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

src/main.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn main() {
2828
subject_stack.push_back(subject.clone());
2929

3030
for (key, val) in obj {
31-
property = Some(format!("https://decisym/json2rdf/#{}", key));
31+
property = Some(format!("http://decisym/data/json2rdf/#{}/", key));
3232
process_value(&mut subject_stack, &property, val, &mut graph);
3333
}
3434

@@ -48,7 +48,12 @@ fn main() {
4848
}
4949
}
5050

51-
51+
for triple in graph.iter() {
52+
println!(
53+
"Subject: {}, Predicate: {}, Object: {}",
54+
triple.subject, triple.predicate, triple.object
55+
);
56+
}
5257
}
5358

5459
fn process_value(
@@ -59,7 +64,6 @@ fn process_value(
5964
) {
6065
if let Some(last_subject) = subject_stack.clone().back() {
6166
if let Some(prop) = property {
62-
// println!("Processing property: {}", prop);
6367
match value {
6468
Value::Bool(b) => {
6569
// println!("{},{},{}", subject_stack.back().unwrap(), prop, b);
@@ -100,21 +104,15 @@ fn process_value(
100104
let subject = BlankNode::default();
101105
subject_stack.push_back(subject);
102106

103-
// println!(
104-
// "{},{},{}",
105-
// last_subject,
106-
// prop,
107-
// subject_stack.back().unwrap()
108-
// );
109-
110107
graph.insert(TripleRef::new(
111108
subject_stack.back().unwrap(),
112109
NamedNodeRef::new(prop.as_str()).unwrap(),
113110
subject_stack.back().unwrap(),
114111
));
115112

116113
for (key, val) in obj {
117-
let nested_property = Some(format!("#{}", key));
114+
let nested_property =
115+
Some(format!("http://decisym/data/json2rdf/#{}/", key));
118116
process_value(subject_stack, &nested_property, val, graph);
119117
}
120118
subject_stack.pop_back();

0 commit comments

Comments
 (0)