Skip to content

Commit 73e0fde

Browse files
committed
minor changes for release, including version bump to 1.2.0
1 parent ff3be6c commit 73e0fde

12 files changed

+37
-40
lines changed

DESCRIPTION

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: rjsoncons
22
Title: 'C++' Header-Only 'jsoncons' Library for 'JSON' Queries
3-
Version: 1.1.0.9500
3+
Version: 1.2.0
44
Authors@R: c(
55
person(
66
"Martin", "Morgan", role = c("aut", "cre"),
@@ -20,10 +20,12 @@ Description: The 'jsoncons'
2020
<https://danielaparker.github.io/jsoncons/> 'C++' header-only
2121
library constructs representations from a 'JSON' character vector,
2222
and provides extensions for flexible queries and other operations
23-
on 'JSON' objects. This package has simple 'R' wrappers to support
24-
'JSONpath' and 'JMESpath' queries into 'JSON' strings or 'R'
25-
objects. The 'jsoncons' library is also be easily linked to other
26-
packages for direct access to 'C++' functionality.
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+
expression. The 'jsoncons' library is also be easily linked to
28+
other packages for direct access to 'C++' functionality.
2729
Imports: utils
2830
Suggests: jsonlite, tibble, cli, tinytest, BiocStyle, knitr, rmarkdown
2931
LinkingTo: cpp11

NEWS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
- (0.0.3) support object names ordering 'asis' or 'sort'
3535
- (0.0.3) DESCRIPTION file updates: correct 'Title:' capitalization;
3636
avoid warnings about most misspellings
37-
- (0.0.3) Add github action to rebuild README.md from
37+
- (0.0.3) Add GitHub action to rebuild README.md from
3838
vignettes/rjsoncons.Rmd
3939
- (0.0.2) jsoncons library update
4040
- (0.0.2) support for R object query in addition to JSON string

R/j_data_type.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#' @title Detect JSON / NDJSON data and path types
3737
#'
3838
#' @description `j_data_type()` uses simple rules to determine whether
39-
#' 'data' is json, ndjson, file, url, or R.
39+
#' 'data' is JSON, NDJSON, file, url, or R.
4040
#'
4141
#' @inheritParams j_query
4242
#'

R/paths_and_pointer.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#' @title JSONpath, JMESpath, or JSONpointer query of JSON / NDJSON documents
44
#'
55
#' @description `jsonpath()` executes a query against a JSON string or
6-
#' vector NDJSON entries using the 'jsonpath' specification.
6+
#' vector NDJSON entries using the 'JSONpath' specification.
77
#'
88
#' @param data a character() JSON string or NDJSON records, or an *R*
99
#' object parsed to a JSON string using `jsonlite::toJSON()`.
@@ -88,7 +88,7 @@ jsonpath <-
8888
#' @rdname paths_and_pointer
8989
#'
9090
#' @description `jmespath()` executes a query against a JSON string
91-
#' using the 'jmespath' specification.
91+
#' using the 'JMESpath' specification.
9292
#'
9393
#' @examples
9494
#' path <- "locations[?state == 'WA'].name | sort(@)"

README.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77

88
The [jsoncons][] C++ header-only library constructs representations
99
from a JSON character vector, and provides extensions for flexible
10-
queries and other operations on JSON objects. This package has simple
11-
'R' wrappers to support [JSONpath][], [JMESpath][], and
12-
[JSONpointer][] queries into JSON strings or 'R' objects. The
13-
'jsoncons' library is also easily linked to other packages for direct
14-
access to 'C++' functionality.
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.
1517

1618
[JSONpath]: https://goessner.net/articles/JsonPath/
1719
[JMESpath]: https://jmespath.org/
@@ -22,7 +24,7 @@ access to 'C++' functionality.
2224
Install the released package version from CRAN
2325

2426
``` r
25-
install.pacakges("rjsoncons", repos = "https://CRAN.R-project.org")
27+
install.packages("rjsoncons", repos = "https://CRAN.R-project.org")
2628
```
2729

2830
Install the development version with

cran-comments.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# Release 1.1.0
1+
# Release 1.2.0
22

3-
- updates 'jsoncons' third party library to 0.172.1 to address
4-
segfault on 'fedora' CRAN builder
5-
- upstream bug report at
6-
<https://github.com/danielaparker/jsoncons/issues/471>
3+
- updates R functionality as described in NEWS.md

man/j_data_type.Rd

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

man/paths_and_pointer.Rd

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

src/j_as.h

+1-6
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,10 @@ cpp11::sexp j_as(Json j, rjsoncons::as as)
219219
switch(as) {
220220
case as::string: return as_sexp( j.template as<std::string>() );
221221
case as::R: return as_r<Json>(j);
222+
default: cpp11::stop("`as_r()` unknown `as = `");
222223
}
223224
}
224225

225-
template<class Json>
226-
cpp11::sexp j_as(Json j, std::string as)
227-
{
228-
j_as(j, enum_index(as_map, as));
229-
}
230-
231226
template<class Json>
232227
sexp as_r_impl(const std::string data)
233228
{

src/r_json.h

+1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ class r_json
167167
return jsonpointer::get<Json>(j, jsonpointer_);
168168
case path_type::JSONpath: return jsonpath_.evaluate(j);
169169
case path_type::JMESpath: return jmespath_.evaluate(j);
170+
default: cpp11::stop("`j_query()` unknown 'path_type'");
170171
}
171172
}
172173

vignettes/a_rjsoncons.Rmd

+10-10
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ the package for direct access to the 'jsoncons' C++ library.
3535
Install the released package version from CRAN
3636

3737
```{r install, eval = FALSE}
38-
install.pacakges("rjsoncons", repos = "https://CRAN.R-project.org")
38+
install.packages("rjsoncons", repos = "https://CRAN.R-project.org")
3939
```
4040

4141
Install the development version with
@@ -72,7 +72,7 @@ json <- '{
7272
```
7373

7474
There are several common use cases. Use [rjsoncons][] to query the
75-
JSON string using [JSONpath][], [JMESPath][] or [JSONpointer][]
75+
JSON string using [JSONpath][], [JMESpath][] or [JSONpointer][]
7676
syntax to filter larger documents to records of interest, e.g., only
7777
cities in New York state, using 'JMESpath' syntax.
7878

@@ -192,19 +192,19 @@ j_query(ndjson_file, "{id: id, type: type}", n_records = 5)
192192
`j_pivot()` transforms an NDJSON file or character vector of objects
193193
into a format convenient for input in *R*. `j_pivot()` with NDJSON
194194
files and JMESpath paths work particularly well together, because
195-
JMESpath provides flexiblity in creating JSON objects to be pivotted.
195+
JMESpath provides flexibility in creating JSON objects to be pivoted.
196196

197197
```{r ndjson_j_pivot}
198198
j_pivot(ndjson_file, "{id: id, type: type}", as = "data.frame")
199199
```
200200

201201
Filtering NDJSON files can require relatively more complicated paths,
202-
e.g., to filt 'PushEvent' types from organizations, construct a query
203-
that acts on each NDJSON record to return an array of a single object,
204-
then apply a filter to replace uninteresting elements with 0-length
205-
arrays (using `as = "tibble"` often transforms the *R* list-of-vectors
206-
to a tibble in a more pleasing and robust manner compared to `as =
207-
"data.frame"`).
202+
e.g., to filter 'PushEvent' types from organizations, construct a
203+
query that acts on each NDJSON record to return an array of a single
204+
object, then apply a filter to replace uninteresting elements with
205+
0-length arrays (using `as = "tibble"` often transforms the *R*
206+
list-of-vectors to a tibble in a more pleasing and robust manner
207+
compared to `as = "data.frame"`).
208208

209209
```{r ndjson_j_pivot_filter}
210210
path <-
@@ -218,7 +218,7 @@ vignette][ndjson-extended]
218218

219219
[NDJSON]: https://ndjson.org/
220220
[GitHub Archive]: https://www.gharchive.org/
221-
[ndjson-extended]: https://mtmrogan.github.io/rjsoncons/articles/b_ndjson.html
221+
[ndjson-extended]: https://mtmorgan.github.io/rjsoncons/articles/b_ndjson_extended.html
222222
[cli]: https://CRAN.R-project.org/package=cli
223223

224224
# The JSON parser

vignettes/articles/b_ndjson_extended.Rmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ adopted to achieve reasonable performance.
330330
[duckdb-json]: https://duckdb.org/2023/03/03/json.html#github-archive-examples
331331
[blog post]: https://mtmorgan.github.io/software/update/2024/01/25/rjsoncons-ndjson-performance.html
332332

333-
# Session inforation {.unnumbered}
333+
# Session information {.unnumbered}
334334

335335
```{r}
336336
sessionInfo()

0 commit comments

Comments
 (0)