Closed NeroBlackstone closed 3 days ago
Maybe we can implement an api like:
function Serde.isempty(::Type{Foo}, x::Int,::Val{:cant_zero})
return x == 0
end
to indicate field we want to apply empty values handling.
HI, @NeroBlackstone! You have a valid a point, IMO. There's a function in serialization submodule called ser_ignore_field
(take a look at the docs). I see no reason to not have something like de_ignore_field
.
Would you like to contribute?
HI, @NeroBlackstone! You have a valid a point, IMO. There's a function in serialization submodule called
ser_ignore_field
(take a look at the docs). I see no reason to not have something likede_ignore_field
.Would you like to contribute?
I don't know if I can understand the source code! But I will try to read some tomorrow!
You can always ask here or in a PR. I'll help with the code and the review once you're ready.
I still think that isempty is a property of the type, not the field
using Serde
struct Foo
nonull_field1::Int
nonull_field2::Int
could_null::Union{Nothing,Int}
function Foo(
nonull_field1::Int,
nonull_field2::Int,
could_null::Union{Nothing,Int}
)
return new(nonull_field1, nonull_field2, could_null == 0 ? nothing : could_null)
end
end
julia> Serde.deser(Foo, Dict("nonull_field1" => 0, "nonull_field2" => 0, "could_null" => 0))
Foo(0, 0, nothing)
Thanks to bhftbootcamp for developing such a great julia library! So elegant!
Currently, Empty values handling cannot be applied to a single field:
This will cause an error: