Skip to content

case_sparql_select: Add JSON output mode #91

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

Merged
merged 2 commits into from
Dec 8, 2022

Conversation

ajnelson-nist
Copy link
Member

This was suggested by a community member.

This patch series adds JSON output using the to_json method provided by Pandas. This is keeping with the pattern of the other output mode functions already used in case_sparql_select (to_html, to_markdown, and to_csv).

JSON output entails some configuration needs:

  • pandas has several options available in its orient parameter for to_json(). This is now exposed to the command line with --json-orient.
  • The indent parameter affects JSON formatting handled elsewhere in case-utils's tests with Python's built-in python3 -m json.tool. The indent option is now exposed to the command line with --json-indent.
  • The to_json() parameter date_format offers two options, epoch (milliseconds) or iso (ISO-8601 string, as with xsd:dateTime). The default value chosen varies depending on the orient parameter to to_json. To relieve the user of needing side-effect knowledge, and to maintain timestamp management through the RDF pipeline, only iso is passed by case_sparql_select.

This should be merged after #90 is merged, as it is built on the patch in 90.

This patch is code-motion to give function names to chunks of
`case_sparql_select:main`.

Some upcoming patch series are going to add features that, when taken
together, introduce non-trivial parameter-value cross-dependencies.

Moving functionality to functions enables combinatoric testing in a
`pytest` space, rather than resorting to copying, pasting, and tweaking
many Makefile lines.  A future patch series will add the `pytest`
script.

Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
No effects were observed on Make-managed files.

Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
@ajnelson-nist ajnelson-nist marked this pull request as ready for review December 8, 2022 13:53
@kchason kchason merged commit c76ace0 into develop Dec 8, 2022
@ajnelson-nist ajnelson-nist deleted the case_sparql_select_add_json_output branch April 28, 2023 20:30
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.

2 participants