Skip to content

Commit 2c442a5

Browse files
committed
Merge branch '1.3-prerelease'
2 parents 92604d0 + d57dc5b commit 2c442a5

File tree

9 files changed

+146
-42
lines changed

9 files changed

+146
-42
lines changed

.github/workflows/rhub.yaml

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# R-hub's generic GitHub Actions workflow file. It's canonical location is at
2+
# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml
3+
# You can update this file to a newer version using the rhub2 package:
4+
#
5+
# rhub::rhub_setup()
6+
#
7+
# It is unlikely that you need to modify this file manually.
8+
9+
name: R-hub
10+
run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}"
11+
12+
on:
13+
workflow_dispatch:
14+
inputs:
15+
config:
16+
description: 'A comma separated list of R-hub platforms to use.'
17+
type: string
18+
default: 'linux,windows,macos'
19+
name:
20+
description: 'Run name. You can leave this empty now.'
21+
type: string
22+
id:
23+
description: 'Unique ID. You can leave this empty now.'
24+
type: string
25+
26+
jobs:
27+
28+
setup:
29+
runs-on: ubuntu-latest
30+
outputs:
31+
containers: ${{ steps.rhub-setup.outputs.containers }}
32+
platforms: ${{ steps.rhub-setup.outputs.platforms }}
33+
34+
steps:
35+
# NO NEED TO CHECKOUT HERE
36+
- uses: r-hub/actions/setup@v1
37+
with:
38+
config: ${{ github.event.inputs.config }}
39+
id: rhub-setup
40+
41+
linux-containers:
42+
needs: setup
43+
if: ${{ needs.setup.outputs.containers != '[]' }}
44+
runs-on: ubuntu-latest
45+
name: ${{ matrix.config.label }}
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
config: ${{ fromJson(needs.setup.outputs.containers) }}
50+
container:
51+
image: ${{ matrix.config.container }}
52+
53+
steps:
54+
- uses: r-hub/actions/checkout@v1
55+
- uses: r-hub/actions/platform-info@v1
56+
with:
57+
token: ${{ secrets.RHUB_TOKEN }}
58+
job-config: ${{ matrix.config.job-config }}
59+
- uses: r-hub/actions/setup-deps@v1
60+
with:
61+
token: ${{ secrets.RHUB_TOKEN }}
62+
job-config: ${{ matrix.config.job-config }}
63+
- uses: r-hub/actions/run-check@v1
64+
with:
65+
token: ${{ secrets.RHUB_TOKEN }}
66+
job-config: ${{ matrix.config.job-config }}
67+
68+
other-platforms:
69+
needs: setup
70+
if: ${{ needs.setup.outputs.platforms != '[]' }}
71+
runs-on: ${{ matrix.config.os }}
72+
name: ${{ matrix.config.label }}
73+
strategy:
74+
fail-fast: false
75+
matrix:
76+
config: ${{ fromJson(needs.setup.outputs.platforms) }}
77+
78+
steps:
79+
- uses: r-hub/actions/checkout@v1
80+
- uses: r-hub/actions/setup-r@v1
81+
with:
82+
job-config: ${{ matrix.config.job-config }}
83+
token: ${{ secrets.RHUB_TOKEN }}
84+
- uses: r-hub/actions/platform-info@v1
85+
with:
86+
token: ${{ secrets.RHUB_TOKEN }}
87+
job-config: ${{ matrix.config.job-config }}
88+
- uses: r-hub/actions/setup-deps@v1
89+
with:
90+
job-config: ${{ matrix.config.job-config }}
91+
token: ${{ secrets.RHUB_TOKEN }}
92+
- uses: r-hub/actions/run-check@v1
93+
with:
94+
job-config: ${{ matrix.config.job-config }}
95+
token: ${{ secrets.RHUB_TOKEN }}

DESCRIPTION

+11-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: rjsoncons
2-
Title: 'C++' Header-Only 'jsoncons' Library for 'JSON' Queries
3-
Version: 1.2.0.9900
2+
Title: Query, Pivot, Patch, and Validate 'JSON' and 'NDJSON'
3+
Version: 1.3.0
44
Authors@R: c(
55
person(
66
"Martin", "Morgan", role = c("aut", "cre"),
@@ -16,18 +16,15 @@ Authors@R: c(
1616
email = "[email protected]",
1717
comment = "jsoncons C++ library maintainer"
1818
))
19-
Description: The 'jsoncons'
20-
<https://danielaparker.github.io/jsoncons/> 'C++' header-only
21-
library constructs representations from a 'JSON' character vector,
22-
and provides extensions for flexible queries and other operations
23-
on 'JSON' objects. This package provides 'R' functions to query
24-
(filter or transform) and pivot (convert from array-of-objects to
25-
object-of-arrays, for easy import into 'R') 'JSON' or 'NDJSON'
26-
strings or files using 'JSONpointer', 'JSONpath' or 'JMESpath'
27-
expressions. The package also supports 'JSON' patch for
28-
conveniently editing JSON documents, and 'JSON' schema for
29-
validation. The 'jsoncons' library is easily linked to other
30-
packages for direct access to 'C++' functionality.
19+
Description: Functions to query (filter or transform), pivot (convert
20+
from array-of-objects to object-of-arrays, for easy import as 'R'
21+
data frame), search, patch (edit), and validate (against 'JSON
22+
Schema') 'JSON' and 'NDJSON' strings, files, or URLs. Query and
23+
pivot support 'JSONpointer', 'JSONpath' or 'JMESpath'
24+
expressions. The implementation uses the 'jsoncons'
25+
<https://danielaparker.github.io/jsoncons/> header-only library;
26+
the library is easily linked to other packages for direct access
27+
to 'C++' functionality not implemented here.
3128
Imports: cli
3229
Suggests: jsonlite, tibble, tinytest, BiocStyle, knitr, rmarkdown
3330
LinkingTo: cpp11, cli

R/patch.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ J_PATCH_OP <- c("add", "remove", "replace", "copy", "move", "test")
6262
#' `jsonlite::toJSON()` argument `auto_unbox = TRUE` when `patch` is
6363
#' an *R* object and any 'value' fields are JSON scalars; for more
6464
#' complicated scenarios 'value' fields should be marked with
65-
#' `jsonlite::unbox()` before being passsed to `j_patch_*()`.
65+
#' `jsonlite::unbox()` before being passed to `j_patch_*()`.
6666
#'
6767
#' For `j_patch_op()` the `...` are additional arguments to the patch
6868
#' operation, e.g., `path = ', `value = '.

R/schema.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ do_j_schema <-
2323
#' 'schema'.
2424
#'
2525
#' @param data JSON character vector, file, or URL defining document
26-
#' to be valdiated. NDJSON data and schema are not supported.
26+
#' to be validated. NDJSON data and schema are not supported.
2727
#'
2828
#' @param schema JSON character vector, file, or URL defining the
29-
#' schema aganist which `data` will be validated.
29+
#' schema against which `data` will be validated.
3030
#'
3131
#' @param ... passed to `jsonlite::toJSON` when `data` is not
3232
#' character-valued.

README.md

+17-13
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
![CRAN downloads](https://cranlogs.r-pkg.org/badges/last-month/rjsoncons)
66
<!-- badges: end -->
77

8-
The [jsoncons][] C++ header-only library constructs representations
9-
from a JSON character vector, and provides extensions for flexible
10-
queries and other operations on JSON objects. This package provides
11-
'R' functions to query (filter or transform) and pivot (convert from
12-
array-of-objects to object-of-arrays, for easy import into 'R') 'JSON'
13-
or 'NDJSON' strings or files using [JSONpath][], [JMESpath][], and
14-
[JSONpointer][] expressions. The package also makes it easy to use C++
15-
'jsoncons' in other *R* packages for direct access to 'C++'
16-
functionality.
17-
8+
This package provides functions to query (filter or transform), pivot
9+
(convert from array-of-objects to object-of-arrays, for easy import as
10+
'R' data frame), search, patch (edit), and validate (against [JSON
11+
Schema][]) 'JSON' and 'NDJSON' strings, files, or URLs. Query and
12+
pivot support [JSONpointer][], [JSONpath][] or [JMESpath][]
13+
expressions. The implementation uses the [jsoncons][] header-only
14+
library; the library is easily linked to other packages for direct
15+
access to 'C++' functionality not implemented here.
16+
17+
[JSON Schema]: https://json-schema.org
1818
[JSONpath]: https://goessner.net/articles/JsonPath/
1919
[JMESpath]: https://jmespath.org/
2020
[JSONpointer]: https://datatracker.ietf.org/doc/html/rfc6901
@@ -48,9 +48,13 @@ library(rjsoncons)
4848

4949
The [introductory vignette][] outlines common use cases, including:
5050

51-
- Filtering large JSON documents to extract records of interest.
52-
- Extracting deeply nested elements.
53-
- Transforming data for more direct incorporation in *R* data structures.
51+
- Filter large JSON or NDJSON documents to extract records or elements
52+
of interest.
53+
- Extract deeply nested elements.
54+
- Transform data for more direct incorporation in *R* data structures.
55+
- 'Patch' JSON strings programmatically, e.g., to update HTTP request
56+
payloads.
57+
- Validate JSON documents against JSON schemas
5458

5559
The [jsoncons][] C++ header-only library is a very useful starting
5660
point for advanced JSON manipulation. The vignette outlines how

cran-comments.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# Release 1.2.0
1+
# Release 1.3.0
22

33
- updates R functionality as described in NEWS.md

man/patch.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/schema.Rd

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vignettes/a_rjsoncons.Rmd

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "Using 'jsoncons' in R"
2+
title: "Transform and Validate JSON and NDJSON"
33
author:
44
- name: Martin Morgan
55
affiliation: Roswell Park Comprehensive Cancer Center, Buffalo, NY, US
@@ -8,7 +8,7 @@ author:
88
output:
99
BiocStyle::html_document
1010
vignette: |
11-
%\VignetteIndexEntry{Using the 'jsoncons' Library in R}
11+
%\VignetteIndexEntry{Transform and Validate JSON and NDJSON}
1212
%\VignetteEngine{knitr::rmarkdown}
1313
%\VignetteEncoding{UTF-8}
1414
---
@@ -21,11 +21,11 @@ knitr::opts_chunk$set(
2121

2222
# Introduction & installation
2323

24-
Use [rjsoncons][] for querying JSON, NDJSON, or R objects using
25-
[JMESpath][], [JSONpath][], or [JSONpointer][]. [rjsoncons][] supports
26-
[JSON patch][] for document editing, and [JSON schema][]
27-
validation. Link to the package for direct access to additional
28-
features in the '[jsoncons][]' C++ library.
24+
Use [rjsoncons][] for querying, transforming, and searching JSON,
25+
NDJSON, or R objects using [JMESpath][], [JSONpath][], or
26+
[JSONpointer][]. [rjsoncons][] supports [JSON patch][] for document
27+
editing, and [JSON schema][] validation. Link to the package for
28+
direct access to additional features in the [jsoncons][] C++ library.
2929

3030
[jsoncons]: https://github.com/danielaparker/jsoncons/
3131
[rjsoncons]: https://mtmorgan.github.io/rjsoncons/
@@ -395,7 +395,7 @@ j_schema_validate(op, schema, as = "tibble") |>
395395
```
396396

397397
The validation indicates that the schema `evaluationPath`
398-
'/items/oneOf' is not satisfied, becuases of the `error` 'No schema
398+
'/items/oneOf' is not satisfied, because of the `error` 'No schema
399399
[i.e., 'oneOf' elements] matched, ...'.
400400

401401
The 'details' column summarizes why each of the 3 elements of
@@ -615,6 +615,14 @@ the query as a JSON string, e.g., using the `fromJSON()` in the
615615
[jsonlite][] package.
616616

617617
```{r jsonlite_fromJSON}
618+
json <- '{
619+
"locations": [
620+
{"name": "Seattle", "state": "WA"},
621+
{"name": "New York", "state": "NY"},
622+
{"name": "Bellevue", "state": "WA"},
623+
{"name": "Olympia", "state": "WA"}
624+
]
625+
}'
618626
j_query(json, "locations[?state == 'WA']") |>
619627
## `fromJSON()` simplifies list-of-objects to data.frame
620628
jsonlite::fromJSON()

0 commit comments

Comments
 (0)