Failed parsing shows like this:
box::use(sr = structr)
packageVersion("structr")
#> [1] '0.1.0.9000'
schema = sr$s_map(
x = sr$s_integer(),
y = sr$s_double(),
z = sr$s_optional(sr$s_string())
) |>
sr$build_structure()
json_str_1 = '{"x": 1.1, "y": 99.9, "z": "value"}'
sr$parse_json(json_str_1, schema)
#> Error in `sr$parse_json()`:
#> ! ExpectedSigned at character 0
Created on 2025-04-26 with reprex v2.1.1
Error message could say something like "Expected an integer for x, but got a double". If x was nested in y, we could say "Expected foo at y$x, but got bar".
structr fills a much needed void in the R ecosystem which was lacking pydantic like schema manager. Thanks for writing this.