Skip to content

Using Grel Slice On a JSON Array Results in an Error #249

@tobiasschweizer

Description

@tobiasschweizer

Hi there,

I've tried to use the grel:array_slice function (https://users.ugent.be/~bjdmeest/function/grel.ttl#array_slice, https://openrefine.org/docs/manual/grelfunctions#slicea-n-from-n-to-optional) on a JSON input array. It results in an error message:

15:29:02.580 [main] ERROR be.ugent.rml.cli.Main .run(442) - For input string: "one"
java.lang.NumberFormatException: For input string: "one"

I am using RMLMapper 7.3.0.

I would expect the following values to be serialized for schema:name: "two" and "three" (since param_int_i_from is 1 and the first element has the index 0).

Data:

{
  "id": "unique",
  "name": ["one", "two", "three"]
}

Mapping:

@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 schema: <http://schema.org/>.
@prefix wgs84_pos: <http://www.w3.org/2003/01/geo/wgs84_pos#lat>.
@prefix gn: <http://www.geonames.org/ontology#>.
@prefix carml: <http://carml.taxonic.com/carml/> .
@prefix fnml: <http://semweb.mmlab.be/ns/fnml#> .
@prefix grel: <http://users.ugent.be/~bjdmeest/function/grel.ttl#> .
@prefix fno: <https://w3id.org/function/ontology#> .
@base <http://example.com/ns#>.
PREFIX ex: <http://example.org/>

<#LogicalSource> a rml:BaseSource ;
  rml:referenceFormulation ql:JSONPath;
  rml:source "data/test.json" ;
  rml:iterator "$" .

<#AuthorMapping> a rr:TriplesMap ;
  rml:logicalSource <#LogicalSource> ;

  rr:subjectMap [
    rr:template "https://example.com/{id}";
    rr:class schema:Thing
  ] ;

  rr:predicateObjectMap [
    rr:predicate schema:name ;
    rr:objectMap [
      fnml:functionValue <#FunctionValueSlice> ;
    ]
  ] .

<#FunctionValueSlice>
    rr:predicateObjectMap [
           rr:predicate fno:executes ;
           rr:objectMap [ rr:constant grel:array_slice ]
        ] ;

        rr:predicateObjectMap [
            rr:predicate grel:p_array_a ;
            rr:objectMap [
                rml:reference "name" ;
            ]
        ] ;

        rr:predicateObjectMap [
            rr:predicate grel:param_int_i_from ;
            rr:objectMap [
                rr:constant "1"^^xsd:int
            ]
        ] .

        #rr:predicateObjectMap [
        #    rr:predicate grel:param_int_i_opt_to ;
        #    rr:objectMap [
        #        rr:constant "2"^^xsd:int
        #    ]
        #] .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions