RMLio / RML-Processor

16 stars 13 forks source link

upgrade JsonPath implementation #3

Closed pebbie closed 8 years ago

pebbie commented 8 years ago

Sample test-case using JSON input (from WorldBank)

[
{"page":1,"pages":1,"per_page":"5000","total":56},
[{"indicator":{"id":"SP.POP.TOTL","value":"Population, total"},"country":{"id":"GB","value":"United Kingdom"},"value":null,"decimal":"0","date":"2015"}]
]

JSON Path 1: $[1] JSON Path 2: $[1].*

using the version of JayWay JsonPath in the current pom.xml (0.9.1), the result of Path 1 would be

[{"indicator":{"id":"SP.POP.TOTL","value":"Population, total"},"country":{"id":"GB","value":"United Kingdom"},"value":null,"decimal":"0","date":"2015"}]

but Path 2 will result

[{"id":"SP.POP.TOTL","value":"Population, total"},{"id":"GB","value":"United Kingdom"},null,"0","2015"}]

These results are different with other JsonPath implementation (Goessner).

in the latest version of JayWay JsonPath (2.2.0), the output of Path 1 and Path 2 is compatible with Goessner implementation (given option "always return result list"). test here

in the JSONPathProcessor this can be done by simply adding JsonPath.using(Configuration.defaultConfiguration().addOptions(Option.ALWAYS_RETURN_LIST)); before compiling the reference in the first execute method (JsonPath path = JsonPath.compile(reference);).

I also suggest adding Lang3 into the pom (commons-lang3) and changing import namespace in be.ugent.mmlab.rml.xml.NamespaceContextAdapter from com.sun.org.apache.xml.internal.utils.PrefixResolver into org.apache.xml.utils.PrefixResolver since the former is marked as internal proprietary API.

Cheers,