Migrating some scripts from JSON3.jl to JSON.jl, I found that JSON.parse() do not restore the column order when writing / parsing a DataFrame :
test_df = DataFrame(a=[1,2,3],b=["b","bb","bbb"],c=[Date(now()),Date(2026,9,7),Date(2000,1,1)],d=rand(3))
df_json = JSON.json(Tables.rowtable(test_df))
df_json3 = JSON3.write(Tables.rowtable(test_df))
df = DataFrame(JSON.parse(df_json))
# 3×4 DataFrame
# Row │ c b a d
# │ String String Int64 Float64
# ─────┼─────────────────────────────────────
# 1 │ 2026-09-07 b 1 0.209237
# 2 │ 2026-09-07 bb 2 0.250778
# 3 │ 2000-01-01 bbb 3 0.557584
# => KO, random column order ?
df3 = DataFrame(JSON3.read(df_json3)) # OK
# 3×4 DataFrame
# Row │ a b c d
# │ Int64 String String Float64
# ─────┼─────────────────────────────────────
# 1 │ 1 b 2026-09-07 0.209237
# 2 │ 2 bb 2026-09-07 0.250778
# 3 │ 3 bbb 2000-01-01 0.557584
# => OK, same column order as original dataframe
Is there any solution to keep the initial column order using JSON.jl (without storing the initial order and reordering the columns after) ?
Migrating some scripts from JSON3.jl to JSON.jl, I found that JSON.parse() do not restore the column order when writing / parsing a DataFrame :
Is there any solution to keep the initial column order using JSON.jl (without storing the initial order and reordering the columns after) ?