-
Notifications
You must be signed in to change notification settings - Fork 14
Open
@AlexAxthelm
Description
Hi,
I've been working with json_schema$serialise() recently, and I'm seeing that when I attempt to serialise an object using a composed/cobined schema (anything using $ref), the returned values are always arrays.
schema <- '{ "$schema": "http://json-schema.org/draft-04/schema#", "definitions": { "city": { "type": "string" } }, "type": "object", "properties": { "city": { "$ref": "#/definitions/city" } } }' validator <- jsonvalidate::json_schema$new(schema) out <- validator$serialise(list(city = "Firenze")) print(out) #> {"city":["Firenze"]} validator$validate(out, verbose = TRUE) #> [1] FALSE #> attr(,"errors") #> instancePath schemaPath keyword type message schema #> 1 /city #/definitions/city/type type string must be string string #> type data dataPath #> 1 string Firenze /city
Created on 2024年01月15日 with reprex v2.0.2
Session info
sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.3.2 (2023年10月31日) #> os macOS Sonoma 14.2 #> system aarch64, darwin23.0.0 #> ui unknown #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Europe/Belgrade #> date 2024年01月15日 #> pandoc 3.1.7 @ /opt/homebrew/bin/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> cli 3.6.2 2023年12月11日 [1] CRAN (R 4.3.1) #> curl 5.1.0 2023年10月02日 [1] CRAN (R 4.3.1) #> digest 0.6.33 2023年07月07日 [1] CRAN (R 4.3.1) #> evaluate 0.21 2023年05月05日 [1] CRAN (R 4.3.1) #> fastmap 1.1.1 2023年02月24日 [1] CRAN (R 4.3.1) #> fs 1.6.3 2023年07月20日 [1] CRAN (R 4.3.1) #> glue 1.6.2 2022年02月24日 [1] CRAN (R 4.3.1) #> htmltools 0.5.6 2023年08月10日 [1] CRAN (R 4.3.1) #> jsonlite 1.8.7 2023年06月29日 [1] CRAN (R 4.3.1) #> jsonvalidate 1.4.2 2023年11月07日 [1] Github (ropensci/jsonvalidate@53600f3) #> knitr 1.43 2023年05月25日 [1] CRAN (R 4.3.1) #> lifecycle 1.0.4 2023年11月07日 [1] CRAN (R 4.3.1) #> magrittr 2.0.3 2022年03月30日 [1] CRAN (R 4.3.1) #> purrr 1.0.2 2023年08月10日 [1] CRAN (R 4.3.1) #> R.cache 0.16.0 2022年07月21日 [1] CRAN (R 4.3.1) #> R.methodsS3 1.8.2 2022年06月13日 [1] CRAN (R 4.3.1) #> R.oo 1.25.0 2022年06月12日 [1] CRAN (R 4.3.1) #> R.utils 2.12.2 2022年11月11日 [1] CRAN (R 4.3.1) #> R6 2.5.1 2021年08月19日 [1] CRAN (R 4.3.1) #> Rcpp 1.0.11 2023年07月06日 [1] CRAN (R 4.3.1) #> reprex 2.0.2 2022年08月17日 [1] CRAN (R 4.3.1) #> rlang 1.1.2 2023年11月04日 [1] CRAN (R 4.3.1) #> rmarkdown 2.25 2023年09月18日 [1] CRAN (R 4.3.1) #> sessioninfo 1.2.2 2021年12月06日 [1] CRAN (R 4.3.1) #> styler 1.10.2 2023年08月29日 [1] CRAN (R 4.3.1) #> V8 4.4.0 2023年10月09日 [1] CRAN (R 4.3.1) #> vctrs 0.6.5 2023年12月01日 [1] CRAN (R 4.3.1) #> withr 2.5.2 2023年10月30日 [1] CRAN (R 4.3.1) #> xfun 0.40 2023年08月09日 [1] CRAN (R 4.3.1) #> yaml 2.3.7 2023年01月23日 [1] CRAN (R 4.3.1) #> #> [1] /opt/homebrew/lib/R/4.3/site-library #> [2] /opt/homebrew/Cellar/r/4.3.2/lib/R/library #> #> ──────────────────────────────────────────────────────────────────────────────
The example above is a reprex, but I see the same behavior for definitions defined in separate files ("$ref": "x.json") as well. at a first guess, this seems like the sub-schemas aren't propagating auto_unbox, but I'm out of my depth on JS/V8.
Metadata
Metadata
Assignees
Labels
No labels