Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RML Mapper for array of array in json #42

Open
chiarisilver opened this issue Jun 14, 2018 · 4 comments
Open

RML Mapper for array of array in json #42

chiarisilver opened this issue Jun 14, 2018 · 4 comments

Comments

@chiarisilver
Copy link

chiarisilver commented Jun 14, 2018

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
Copy link
Collaborator

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
Copy link
Author

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

@bjdmeest bjdmeest reopened this Jun 14, 2018
@chiarisilver
Copy link
Author

Unfortunately it doesn't work..

@canarvaeza
Copy link

canarvaeza commented Jun 18, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants