From b7453c4355da7f7270137d32b30a9d4292d2eb50 Mon Sep 17 00:00:00 2001 From: Rich FitzJohn Date: Wed, 6 Nov 2024 11:52:57 +0000 Subject: [PATCH 1/7] Bump version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 92beac2..229f571 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: jsonvalidate Title: Validate 'JSON' Schema -Version: 1.4.2 +Version: 1.5.0 Authors@R: c(person("Rich", "FitzJohn", role = c("aut", "cre"), email = "rich.fitzjohn@gmail.com"), person("Rob", "Ashton", role = "aut"), From a6433677722b7c1da42999bbd937bd1e1ba2f9f2 Mon Sep 17 00:00:00 2001 From: Rich FitzJohn Date: Wed, 6 Nov 2024 11:56:19 +0000 Subject: [PATCH 2/7] Fix spelling --- DESCRIPTION | 2 +- R/schema.R | 2 +- R/serialise.R | 4 ++-- R/validate.R | 4 ++-- inst/WORDLIST | 4 ++++ man/json_schema.Rd | 2 +- man/json_serialise.Rd | 4 ++-- man/json_validator.Rd | 4 ++-- 8 files changed, 15 insertions(+), 11 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 229f571..b0b52b9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -29,7 +29,7 @@ Suggests: rmarkdown, testthat, withr -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 Roxygen: list(markdown = TRUE) VignetteBuilder: knitr Encoding: UTF-8 diff --git a/R/schema.R b/R/schema.R index 0da1b9c..eb78fe4 100644 --- a/R/schema.R +++ b/R/schema.R @@ -5,7 +5,7 @@ ##' @description Interact with JSON schemas, using them to validate ##' json strings or serialise objects to JSON safely. ##' -##' This interface supercedes [jsonvalidate::json_schema] and changes +##' This interface supersedes [jsonvalidate::json_schema] and changes ##' some default arguments. While the old interface is not going ##' away any time soon, users are encouraged to switch to this ##' interface, which is what we will develop in the future. diff --git a/R/serialise.R b/R/serialise.R index 2412351..5a8857f 100644 --- a/R/serialise.R +++ b/R/serialise.R @@ -5,7 +5,7 @@ ##' particular: ##' ##' * R has no scalar types so it is not clear if `1` should be -##' serialised as a number or a vector of length 1; jsonlite +##' serialised as a number or a vector of length 1; `jsonlite` ##' provides support for "automatically unboxing" such values ##' (assuming that length-1 vectors are scalars) or never unboxing ##' them unless asked to using [jsonlite::unbox] @@ -20,7 +20,7 @@ ##' ##' These issues are somewhat lessened when we have a schema because ##' we know what our target type looks like. This function attempts -##' to use the schema to guide serialsation of json safely. Currently +##' to use the schema to guide serialisation of json safely. Currently ##' it only supports detecting the appropriate treatment of length-1 ##' vectors, but we will expand functionality over time. ##' diff --git a/R/validate.R b/R/validate.R index 1e14004..a067ded 100644 --- a/R/validate.R +++ b/R/validate.R @@ -21,7 +21,7 @@ ##' scope this option if you want to quieten it within code you do ##' not control. Alternatively, setting the option ##' `jsonvalidate.no_note_imjv` to `FALSE` will print the message -##' even noninteractively. +##' even non-interactively. ##' ##' Updating the engine should be simply a case of adding `engine ##' = "ajv"` to your `json_validator` or `json_validate` @@ -80,7 +80,7 @@ ##' ##' @return A function that can be used to validate a ##' schema. Additionally, the function has two attributes assigned: -##' `v8` which is the javascript context (used internally) and +##' `v8` which is the JavaScript context (used internally) and ##' `engine`, which contains the name of the engine used. ##' ##' @export diff --git a/inst/WORDLIST b/inst/WORDLIST index 0da3de8..a7f398e 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -1,6 +1,9 @@ +CMD +R's ajv arg codecov +deserialise imjv io js @@ -10,3 +13,4 @@ metaschema org ropensci subschema +unboxable diff --git a/man/json_schema.Rd b/man/json_schema.Rd index cea3e67..a32f864 100644 --- a/man/json_schema.Rd +++ b/man/json_schema.Rd @@ -7,7 +7,7 @@ Interact with JSON schemas, using them to validate json strings or serialise objects to JSON safely. -This interface supercedes \link{json_schema} and changes +This interface supersedes \link{json_schema} and changes some default arguments. While the old interface is not going away any time soon, users are encouraged to switch to this interface, which is what we will develop in the future. diff --git a/man/json_serialise.Rd b/man/json_serialise.Rd index 71403ec..f963976 100644 --- a/man/json_serialise.Rd +++ b/man/json_serialise.Rd @@ -50,7 +50,7 @@ differences between R's types and those available in JSON. In particular: \itemize{ \item R has no scalar types so it is not clear if \code{1} should be -serialised as a number or a vector of length 1; jsonlite +serialised as a number or a vector of length 1; \code{jsonlite} provides support for "automatically unboxing" such values (assuming that length-1 vectors are scalars) or never unboxing them unless asked to using \link[jsonlite:unbox]{jsonlite::unbox} @@ -66,7 +66,7 @@ balancing precision and storage. These issues are somewhat lessened when we have a schema because we know what our target type looks like. This function attempts -to use the schema to guide serialsation of json safely. Currently +to use the schema to guide serialisation of json safely. Currently it only supports detecting the appropriate treatment of length-1 vectors, but we will expand functionality over time. diff --git a/man/json_validator.Rd b/man/json_validator.Rd index 7e5e163..9c8dbb3 100644 --- a/man/json_validator.Rd +++ b/man/json_validator.Rd @@ -32,7 +32,7 @@ https://ajv.js.org/strict-mode.html for details. Only available in \value{ A function that can be used to validate a schema. Additionally, the function has two attributes assigned: -\code{v8} which is the javascript context (used internally) and +\code{v8} which is the JavaScript context (used internally) and \code{engine}, which contains the name of the engine used. } \description{ @@ -60,7 +60,7 @@ option \code{jsonvalidate.no_note_imjv} to \code{TRUE}. Consider using scope this option if you want to quieten it within code you do not control. Alternatively, setting the option \code{jsonvalidate.no_note_imjv} to \code{FALSE} will print the message -even noninteractively. +even non-interactively. Updating the engine should be simply a case of adding \code{engine = "ajv"} to your \code{json_validator} or \code{json_validate} calls, but you may see some issues when doing so. From a5b36ef8de995171c5273a797298f0f52cda1c2c Mon Sep 17 00:00:00 2001 From: Rich FitzJohn Date: Wed, 6 Nov 2024 12:00:49 +0000 Subject: [PATCH 3/7] Update URLs --- README.md | 2 +- vignettes/jsonvalidate.Rmd | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9f812a2..581ecec 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) [![R-CMD-check](https://github.com/ropensci/jsonvalidate/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ropensci/jsonvalidate/actions/workflows/R-CMD-check.yaml) -[![codecov.io](https://codecov.io/github/ropensci/jsonvalidate/coverage.svg?branch=master)](https://codecov.io/github/ropensci/jsonvalidate?branch=master) +[![codecov.io](https://codecov.io/github/ropensci/jsonvalidate/coverage.svg?branch=master)](https://app.codecov.io/github/ropensci/jsonvalidate?branch=master) [![](http://www.r-pkg.org/badges/version/jsonvalidate)](https://cran.r-project.org/package=jsonvalidate) diff --git a/vignettes/jsonvalidate.Rmd b/vignettes/jsonvalidate.Rmd index 2c7c746..4e94e31 100644 --- a/vignettes/jsonvalidate.Rmd +++ b/vignettes/jsonvalidate.Rmd @@ -19,13 +19,13 @@ using [V8](https://cran.r-project.org/package=V8) to do JSON schema validation in R. You need a JSON schema file; see -[json-schema.org](http://json-schema.org) for details on writing +[json-schema.org](https://json-schema.org/) for details on writing these. Often someone else has done the hard work of writing one for you, and you can just check that the JSON you are producing or consuming conforms to the schema. The examples below come from the [JSON schema -website](http://json-schema.org/learn/getting-started-step-by-step.html) +website](https://json-schema.org//learn/getting-started-step-by-step.html) They describe a JSON based product catalogue, where each product has an id, a name, a price, and an optional set of tags. A JSON @@ -44,7 +44,7 @@ The schema that they derive looks like this: ```json { - "$schema": "http://json-schema.org/draft-04/schema#", + "$schema": "https://json-schema.org//draft-04/schema#", "title": "Product", "description": "A product from Acme's catalog", "type": "object", @@ -86,7 +86,7 @@ generally be easiest! Here's a string representing the schema ```{r} schema <- '{ - "$schema": "http://json-schema.org/draft-04/schema#", + "$schema": "https://json-schema.org//draft-04/schema#", "title": "Product", "description": "A product from Acme\'s catalog", "type": "object", @@ -235,7 +235,7 @@ You can combine schemas with `ajv` engine. You can reference definitions within ```{r} schema <- '{ - "$schema": "http://json-schema.org/draft-04/schema#", + "$schema": "https://json-schema.org//draft-04/schema#", "definitions": { "city": { "type": "string" } }, @@ -253,12 +253,12 @@ You can reference schema from other files ```{r} city_schema <- '{ - "$schema": "http://json-schema.org/draft-07/schema", + "$schema": "https://json-schema.org//draft-07/schema", "type": "string", "enum": ["Firenze"] }' address_schema <- '{ - "$schema": "http://json-schema.org/draft-07/schema", + "$schema": "https://json-schema.org//draft-07/schema", "type":"object", "properties": { "city": { "$ref": "city.json" } @@ -278,7 +278,7 @@ You can combine schemas in subdirectories. Note that the `$ref` path needs to be ```{r} user_schema = '{ - "$schema": "http://json-schema.org/draft-07/schema", + "$schema": "https://json-schema.org//draft-07/schema", "type": "object", "required": ["address"], "properties": { From 896f3d23131880c292287928be862f880926db5d Mon Sep 17 00:00:00 2001 From: Rich FitzJohn Date: Wed, 6 Nov 2024 12:01:03 +0000 Subject: [PATCH 4/7] Update licence year --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 824acc8..c8443a7 100644 --- a/LICENSE +++ b/LICENSE @@ -1,2 +1,2 @@ -YEAR: 2016 +YEAR: 2024 COPYRIGHT HOLDER: Rich FitzJohn From fe5c3f2856a4f14a91763021235cf76777ee1ff4 Mon Sep 17 00:00:00 2001 From: Rich FitzJohn Date: Wed, 6 Nov 2024 12:12:00 +0000 Subject: [PATCH 5/7] Revert "Update URLs" This reverts commit a5b36ef8de995171c5273a797298f0f52cda1c2c. --- vignettes/jsonvalidate.Rmd | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vignettes/jsonvalidate.Rmd b/vignettes/jsonvalidate.Rmd index 4e94e31..94c2816 100644 --- a/vignettes/jsonvalidate.Rmd +++ b/vignettes/jsonvalidate.Rmd @@ -44,7 +44,7 @@ The schema that they derive looks like this: ```json { - "$schema": "https://json-schema.org//draft-04/schema#", + "$schema": "http://json-schema.org/draft-04/schema#", "title": "Product", "description": "A product from Acme's catalog", "type": "object", @@ -86,7 +86,7 @@ generally be easiest! Here's a string representing the schema ```{r} schema <- '{ - "$schema": "https://json-schema.org//draft-04/schema#", + "$schema": "http://json-schema.org/draft-04/schema#", "title": "Product", "description": "A product from Acme\'s catalog", "type": "object", @@ -235,7 +235,7 @@ You can combine schemas with `ajv` engine. You can reference definitions within ```{r} schema <- '{ - "$schema": "https://json-schema.org//draft-04/schema#", + "$schema": "http://json-schema.org/draft-04/schema#", "definitions": { "city": { "type": "string" } }, @@ -253,12 +253,12 @@ You can reference schema from other files ```{r} city_schema <- '{ - "$schema": "https://json-schema.org//draft-07/schema", + "$schema": "http://json-schema.org/draft-07/schema", "type": "string", "enum": ["Firenze"] }' address_schema <- '{ - "$schema": "https://json-schema.org//draft-07/schema", + "$schema": "http://json-schema.org/draft-07/schema", "type":"object", "properties": { "city": { "$ref": "city.json" } @@ -278,7 +278,7 @@ You can combine schemas in subdirectories. Note that the `$ref` path needs to be ```{r} user_schema = '{ - "$schema": "https://json-schema.org//draft-07/schema", + "$schema": "http://json-schema.org/draft-07/schema", "type": "object", "required": ["address"], "properties": { From d5c16fcdfcd2c4f2a30a8117627205f6f07769f2 Mon Sep 17 00:00:00 2001 From: Rich FitzJohn Date: Wed, 6 Nov 2024 12:14:54 +0000 Subject: [PATCH 6/7] Fix note about imports --- R/zzz.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/zzz.R b/R/zzz.R index d4ed60c..6155ba0 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -6,6 +6,6 @@ jsonvalidate_js <- function() { ## Via Gabor, remove NOTE about Imports while not loading R6 at load. -function() { +ignore_unused_imports <- function() { R6::R6Class } From 8df0afa8363e9b42cd48f38e30cf9b2d8b3c922f Mon Sep 17 00:00:00 2001 From: Rich FitzJohn Date: Wed, 6 Nov 2024 12:23:11 +0000 Subject: [PATCH 7/7] Fix incorrectly generated rd --- R/serialise.R | 2 +- man/json_serialise.Rd | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/R/serialise.R b/R/serialise.R index 5a8857f..6f8b7ff 100644 --- a/R/serialise.R +++ b/R/serialise.R @@ -43,7 +43,7 @@ ##' schemas contained within a `oneOf` block (or similar) will not be ##' recursed into. ##' -##' @section: Warning: +##' # Warning ##' ##' Direct use of this function will be slow! If you are going to ##' serialise more than one or two objects with a single schema, you diff --git a/man/json_serialise.Rd b/man/json_serialise.Rd index f963976..f66ca59 100644 --- a/man/json_serialise.Rd +++ b/man/json_serialise.Rd @@ -90,9 +90,7 @@ unboxable values will be found - at the moment we know that schemas contained within a \code{oneOf} block (or similar) will not be recursed into. } -\section{}{ - Warning: - +\section{Warning}{ Direct use of this function will be slow! If you are going to serialise more than one or two objects with a single schema, you should use the \code{serialise} method of a