Skip to content

Commit c170ab3

Browse files
committed
remove_nulls now always returns Dict with String keys
1 parent dffc328 commit c170ab3

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

Diff for: src/preprocessing.jl

+2-5
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,13 @@ julia> [nothing, Dict("a" => 1), nothing, Dict("a" => nothing)] |> remove_nulls
1616
```
1717
"""
1818
remove_nulls(x) = x
19-
# In the future we might extend this so that JSON3 objects return also JSON3 objects,
20-
# but given that the result will almost always be directly passed to `schema` or `extract`,
21-
# there seems to be little added value.
2219
remove_nulls(V::AbstractVector) = [v for v in Iterators.map(remove_nulls, V) if !isnothing(v)]
2320
function remove_nulls(d::T) where T <: AbstractDict
24-
res = empty(d)
21+
res = Dict{String, valtype(d)}()
2522
for (k, v) in d
2623
v_res = remove_nulls(v)
2724
if !isnothing(v_res)
28-
res[k] = v_res
25+
res[string(k)] = v_res
2926
end
3027
end
3128
return res

0 commit comments

Comments
 (0)