Skip to content

Add SPARQL JSON output format for results in query - #1297

Open
ptgolden wants to merge 1 commit into
ontodev:masterfrom
ptgolden:query-format-srj
Open

ptgolden wants to merge 1 commit into
ontodev:masterfrom
ptgolden:query-format-srj

Conversation

@ptgolden

Copy link
Copy Markdown
Contributor
  • docs/ have been added/updated
  • tests have been added/updated
  • mvn verify says all tests pass
  • mvn site says all JavaDocs correct
  • CHANGELOG.md has been updated

This adds SPARQL JSON as an output format under its recommended extension:

It is recommended that SPARQL query files have the extension ".srj" (all lowercase) on all platforms.

This mirrors the inclusion of SPARQL XML (as the sxml format).

I did not add any new tests, because I didn't see anything similar. A round-trip between SPARQL JSON and another format would just be testing Jena, not ROBOT.

I was considering adding documentation, because there's nowhere with an exhaustive list of query output formats, and including that would have been a more substantial change. The documentation for query's --format reads:

the query result format: CSV, TSV, TTL, JSONLD, etc.

...so I'll chalk this one up to "etc."

@ptgolden

ptgolden commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor Author

I should add background for why I thought this would be useful-- I'm working on an ODK-based project where I want to do some script-based post-processing on SPARQL results. Round-tripping through {C,T}SV is semantically lossy, and going through XML is possible but slightly annoying (for the reasons working with XML in Python can sometimes be annoying).

If ROBOT does end up adding another member of org.apache.jena.riot.resultset.ResultSetLang, I'll note that the complete catalog of SPARQL result set formats is:

  • SPARQLResultSetCSV
  • SPARQLResultSetJSON
  • SPARQLResultSetNone
  • SPARQLResultSetText
  • SPARQLResultSetThrift
  • SPARQLResultSetTSV
  • SPARQLResultSetXML

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant