jsonlite icon indicating copy to clipboard operation
jsonlite copied to clipboard

empty data.frame round-tripping

Open king-of-poppk opened this issue 1 year ago • 0 comments

It seems there is currently no straightforward way to round-trip empty data frames. The colnames(df) are dropped since they are repeated for each row, but there are no rows! I could not find a way to make fromJSON correctly parse toJSON(df, dataframe = "columns"), and anyway the output is also empty when the input data frame has no rows.

I guess one has to extract header, index, and values manually and do some custom JSON encoding.

king-of-poppk avatar Feb 03 '23 07:02 king-of-poppk