Skip to content

Commit

Permalink
fix: deserialization of JSON rdf serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximvdw committed Feb 17, 2024
1 parent 0602e54 commit 222b026
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/mapping/DataObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,41 @@ SerializableMember({
return undefined;
}

const deserializedPredicates = object.predicates
? Object.keys(object.predicates)
.map((predicate: any) => {
return {
[predicate]: object.predicates[predicate].map((item: any) => {
if (item.termType && item.predicates === undefined) {
switch (item.termType) {
case 'BlankNode':
return DataFactory.blankNode(item.value);
case 'Literal':
const literal = DataFactory.literal(

Check failure on line 155 in src/mapping/DataObject.ts

View workflow job for this annotation

GitHub Actions / Code quality

Unexpected lexical declaration in case block
item.value,
item.language ?? item.datatype
? DataFactory.namedNode(item.datatype.value)
: undefined,
);
return literal;
case 'NamedNode':
return DataFactory.namedNode(item.value);
default:
return item;
}
} else {
return item;
}
}),
};
})
.reduce((a, b) => ({ ...a, ...b }))
: {};
console.log('deserializedPredicates', deserializedPredicates);
return {
path: object.path,
uri: object.uri,
predicates: object.predicates,
predicates: deserializedPredicates,
} as RDFMetadata;
},
})(DataObject.prototype, 'rdf');
Expand Down

0 comments on commit 222b026

Please sign in to comment.