Closed richfitz closed 2 years ago
I've taken quite a different approach here in the end as I started writing out a json_serialiser
object and realised that what we really needed was a reusable "things you can do with a schema" object. I doubt we'll find a 3rd thing but if we did we'd be sorted :)
This PR adds support for a schema-guided serialisation of R objects.
This is best described in the docs and example. Suppose we have this schema:
and we want to serialise this object:
If we use
jsonlite::toJSON
thenid
,name
andprice
end up as length-1 arraysAlternatively if we pass
auto_unbox = TRUE
then tags gets turned into a stringso we typically end up manually marking strings to unbox with
jsonlite::unbox
. We can guide this though with the schema because we can work out what needs to be unboxed:giving