node.js - Frame json-ld document to append children -
i'm trying create frame include every children inside array, detail (see example) must contain other nodes inside itself.
this example of data i'm using, in expanded json-ld:
[ { "@id": "a", "http://ontology.ayvu.net/#person": [ { "@value": "101023", "@type": "http://www.w3.org/2001/xmlschema#integer" } ], "http://ontology.ayvu.net/#detail": [ { "@id": "_:g70157685738360" }, { "@id": "_:g70157685722960" } ] }, { "@id": "_:g70157685722960", "http://ontology.ayvu.net/#deuda": [ { "@value": "oficina" } ], "http://ontology.ayvu.net/#detalle": [ { "@value": "100" "@type": "http://www.w3.org/2001/xmlschema#decimal" } ] }, { "@id": "_:g70157685738360", "http://ontology.ayvu.net/#deuda": [ { "@value": "3573.04", "@type": "http://www.w3.org/2001/xmlschema#decimal" } ], "http://ontology.ayvu.net/#detalle": [ { "@value": "automotores" } ] }
]
the following frame (and sets default vocabulary http://ontology.ayvu.net/#
long urls disappear):
{ "@context": { "@vocab": "http://ontology.ayvu.net/#" }, "detail": {} }
the frame ensures top-level object contains detail
property right root object. children automatically moved down json tree.
the result follows:
{ "@context": { "@vocab": "http://ontology.ayvu.net/#" }, "@graph": [ { "@id": "a", "person": { "@value": "101023" "@type": "http://www.w3.org/2001/xmlschema#integer", }, "detail": [ { "@id": "_:b0", "detalle": "automotores", "deuda": { "@value": "3573.04" "@type": "http://www.w3.org/2001/xmlschema#decimal", } }, { "@id": "_:b1", "detalle": { "@value": "100" "@type": "http://www.w3.org/2001/xmlschema#decimal", }, "deuda": "oficina" } ] } ] }
or live in json-ld playground: http://tinyurl.com/q844vkd
Comments
Post a Comment