You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using JSON3
using StructTypes
Base.@kwdefmutable struct MyType2
c::Float64=3.0MyType2(c) = c <0.0?error("bar") :new(c)
end
Base.@kwdefmutable struct MyType
a::Int=1
b::MyType2=MyType2(3.0)
MyType(a,b) = a >10?error("foo") :new(a,b)
end
StructTypes.StructType(::Type{MyType}) = StructTypes.Mutable()
StructTypes.StructType(::Type{MyType2}) = StructTypes.Mutable()
json_string ="""{"a":11, "b":{"c":-3.0}}"""
hello_world = JSON3.read(json_string, MyType; parsequoted=true)
Dear JSON3.jl maintainers,
Lets assume i have a two mutable structs of MyType2 which is then nested into MyType.
I expect JSON3.read to trow an error since json_string has to invalid input according to inner constructor. My understand is that StuctTypes.Muable() calls an emtpy constructor and then mutates the arguements in order to deal with missing arguments in the json_string. I want it to be able top handly missing arguments but still call the innerconstructor to validate the input.
Is there a way to throw theses errors using StructTypes while parsing the “json_string”.
Due to legacy reasons i don’t want to change the structs to be immutable.
Tips are very appreciated, thank you for your support in advance.
best regards
BlondDon
The text was updated successfully, but these errors were encountered:
Dear JSON3.jl maintainers,
Lets assume i have a two mutable structs of MyType2 which is then nested into MyType.
I expect JSON3.read to trow an error since json_string has to invalid input according to inner constructor. My understand is that StuctTypes.Muable() calls an emtpy constructor and then mutates the arguements in order to deal with missing arguments in the json_string. I want it to be able top handly missing arguments but still call the innerconstructor to validate the input.
Is there a way to throw theses errors using StructTypes while parsing the “json_string”.
Due to legacy reasons i don’t want to change the structs to be immutable.
Tips are very appreciated, thank you for your support in advance.
best regards
BlondDon
The text was updated successfully, but these errors were encountered: