jsonlite
jsonlite copied to clipboard
empty data.frame round-tripping
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.