related post: DataFrames to Database tables
Indeed, my plan is data passing from DataFrame to json. I am trying to use Genie frame work and Genie.json, the sample data is as following,
Row │ id name address age sex
│ Int64 String String? String? String?
─────┼───────────────────────────────────────────
1 │ 1 Ono Kyoto 60 m
2 │ 2 Serena PA 38 F
3 │ 3 Edita Slovakia 32 F
and this data packed to res as DataFrames, then
json( Dict( "alldata" => res ))
the json data is lined order by columns.
(A):{"alldata":{"columns":[[1,2,3], ["Ono","Serana","Edita"],["Kyoto","PA","Slovakia"],["60","38","32"],["m","f","f"]]}}
But, of course, I would like to get each row like this
(B):{"alldata":{"columns":[[1,"Ono","Kyoto","60","m"],[2,"Serana","PA","38","f"],[3,"Edita","Slovakia","32","f"]]}}
I posted the same question on Genie community then got answer using JSON3 package after serialization. That procedure made sense, however I wonder are there any ideas alike do not use serialize processing. The ideal process is direct pass from Dataframes to json to realize (B) json form data.
To json by serializing
oDf::DataFrame = SearchLight.query( sSelect )
if !isempty(oDf)
for oRow in eachrow(oDf)
_iid::Int = oRow.id
_sname::String = oRow.name
・
・
push!( aTmp["alldata"], Dict("columns"=>[_iid,_sname,_saddress,_sage,_ssex]))
end
aTmp["data_ready"] = 1
end
sRetJ = JSON3.write(aTmp)
I looked at DataFrames.jl but did not find the solution, maybe the book has it, but not yet. Thanks any advances.