RMLio / RML-Mapper

Generate High Quality Linked Data from multiple originally (semi-)structured data (legacy)
http://RML.io
52 stars 20 forks source link

RML Mapper for array of array in json #42

Open chiarisilver opened 6 years ago

chiarisilver commented 6 years ago

Hi, I'm trying to map this json file to RDF, but I probably can not iterate correctly to get the values ​​of "value", which are inside the measures array.

Json:

{ "status": 0, "body": { "updatetime": 1528904042, "timezone": "Europe\/Rome", "measuregrps": [{ "grpid": 1154218424, "attrib": 2, "date": 1528902698, "category": 1, "brand": 1, "modified": 1528902700, "deviceid": null, "measures": [{ "value": 7000, "type": 11, "unit": -2, "algo": 0, "fw": 0, "fm": 131 }] }, { "grpid": 1154218987, "attrib": 2, "date": 1528902745, "category": 1, "brand": 1, "modified": 1528902747, "deviceid": null, "measures": [{ "value": 7200, "type": 11, "unit": -2, "algo": 0, "fw": 0, "fm": 131 }] } ] } }

RML: `@prefix rr: http://www.w3.org/ns/r2rml#. @prefix rml: http://semweb.mmlab.be/ns/rml# . @prefix ql: http://semweb.mmlab.be/ns/ql# . @prefix xsd: http://www.w3.org/2001/XMLSchema#. @prefix fo: http://purl.org/ifo/#.

MAPPING

<#RestingHeartRate>

rml:logicalSource [ rml:source "provaJson.json"; rml:referenceFormulation ql:JSONPath; rml:iterator "$.body.measuregrps"; ];

rr:subjectMap [ rr:template "http://ifo.com/{grpid}"; rr:class fo:HeartRate; ];

rr:predicateObjectMap [ rr:predicate fo:hasTemporalRelationshipToPhysicalActivity; rr:objectMap [ rr:constant fo:AtRest; ]; ];

rr:predicateObjectMap [ rr:predicate fo:hasMeasure; rr:objectMap [ rr:parentTriplesMap <#MeasureHeartRate>; ]; ].

<#MeasureHeartRate>

rml:logicalSource [ rml:source "provaJson.json"; rml:referenceFormulation ql:JSONPath; rml:iterator "$.body.measuregrps"; ];

rr:subjectMap [ rr:template "http://ifo.com/{grpid}"; rr:class fo:Measure; rml:iterator "$.body.measuregrps";

];

rr:predicateObjectMap [ rr:predicate fo:hasNumericalValue; rr:objectMap [ rml:reference "@.measures.value"; rr:datatype xsd:float; ]; ];

rr:predicateObjectMap [ rr:predicate fo:hasDescriptiveStatistic; rr:objectMap [ rr:constant fo:average; ]; ];

rr:predicateObjectMap [ rr:predicate fo:hasUnit; rr:objectMap [ rr:constant fo:bpm; ]; ].

`

Thanks, Chiara

bjdmeest commented 6 years ago

Using the JSONPath below gives me access to the values of the value-key, so it should be possible to get the values within a mapping document

$.body.measuregrps[*].measures[*].value
chiarisilver commented 6 years ago

Thank you! But I don't understand which iterator I should assign that path. Thank's!

chiarisilver commented 6 years ago

Unfortunately it doesn't work..

canarvaeza commented 6 years ago

Hi Chiara,

Whats actual output?, the problem is only with value or also with others like fm. 1) I don´t know if you can say this

rr:subjectMap [ rr:template "http://ifo.com/{grpid}"; rr:class fo:Measure; rml:iterator "$.measures";

]; I have seen the iterator only in the rml:logicalSource part.

2) I don't know why you use @ at the path

rr:predicateObjectMap [ rr:predicate fo:hasNumericalValue; rr:objectMap [ rml:reference "@.value"; rr:datatype xsd:float; ]; ];

Try without @.value, only use value since

<#MeasureHeartRate> rml:logicalSource [ rml:iterator "$.body.measuregrps[].measures[]" ]

Will set the dir to the measures and then you can acces value without problems.

Try this command $.body.measuregrps[].measures[].value on http://jsonpath.com/ with your json and make some tests.

Best,

2018-06-14 8:34 GMT-05:00 chiarisilver notifications@github.com:

Unfortunately it doesn't work..

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/RMLio/RML-Mapper/issues/42#issuecomment-397297864, or mute the thread https://github.com/notifications/unsubscribe-auth/AT0gtXYP6FzsnEFbfghJ03DFNY0x_5MWks5t8mZ0gaJpZM4Un7FY .

--

Cristian Andres Narvaez Alarcon Estudiante de Maestría en Ingeniería de Sistemas y Computación Universidad Nacional de Colombia