Hi all-
I am trying to store an array of DataFrames as a JSON file and read the JSON file back as the same array of DataFrames. As far as I can tell, the best approach currently is to use JSONTables. Unfortunately, I am having some trouble. Here is my attempt:
using JSON, JSONTables, DataFrames
dfs = DataFrame[]
df = DataFrame(a = ["a","b","c"], b = [.3,.4,.5], c = [1,2,3])
push!(dfs, df, df)
str = JSON.json(dfs)
jtable = jsontable(str)
new_dfs = DataFrame(jtable)
The output is
2×2 DataFrame. Omitted printing of 1 columns
│ Row │ columns │
│ │ JSON3… │
├─────┼───────────────────────────────────────────────┤
│ 1 │ [["a", "b", "c"], [0.3, 0.4, 0.5], [1, 2, 3]] │
│ 2 │ [["a", "b", "c"], [0.3, 0.4, 0.5], [1, 2, 3]] │
I tried using JSON3 instead of JSON but had no success. How can I modify the code above to reconstruct the array of DataFrames? Thank you.