8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
toJson
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/+dub.sdl: dependency "vibe-serialization" version="*" +/ import std.stdio; import vibe.data.json; @safe: class C { final Json toJson() const @trusted { debug stderr.writeln("C.toJson: ", cast(void*)this); return Json(42); } static typeof(this) fromJson(Json json) @safe { return new C; } } void main() { C a = null; debug writeln(serializeToJson(a)); }
Looks like, if toJson is defined, it is called even when the class instance is null.
null
I'm not sure if this is intentional - looks like it might be a potential footgun. For instance, we have to be careful that toJson is not virtual.
The text was updated successfully, but these errors were encountered:
ae.utils.json has the same issue 🙈
ae.utils.json
Sorry, something went wrong.
Since the normal path explicitly checks for null, definitely looks like an oversight.
No branches or pull requests
Looks like, if
toJson
is defined, it is called even when the class instance isnull
.I'm not sure if this is intentional - looks like it might be a potential footgun. For instance, we have to be careful that
toJson
is not virtual.The text was updated successfully, but these errors were encountered: