jsonlite icon indicating copy to clipboard operation
jsonlite copied to clipboard

A way to specify toJSON schema/unboxing level

Open danilaml opened this issue 8 years ago • 0 comments

Problem: I want to be able to convert to json lists of lists of ... lists of predetermined depth. I.e. I know that the value in x is nested list of depth n. The problem: if I use auto_unbox=TRUE, then something like [[0]] might be converted to [0] (but I'd want it to stay the same), but without auto_unbox=TRUE [1, 2, 3] becomes [[1], [2], [3]], is there a way to workaround this issue, without going through all of my data and marking values at specified length with unbox (I fear it might slow down things quite a bit)? Is there some way to specify the json schema (it's not uncommon to know it beforehand) or at least the threshold unboxing depth level (i.e. only unbox values which are at least n levels "deep") for jsonlite?

Btw, when I used rjson it seemed to always produce desirable result in toJSON (though I'm not 100% sure), though it had unconfigurable handling of single value arrays in fromJSON which lead me to this lib.

danilaml avatar Jun 25 '17 01:06 danilaml