Am 24.05.2016 um 07:54 schrieb Jonathan M Davis:

I'm not sure of the best place to ask this question, but since stddatajson is related to vibe.d, I guess that I'll ask it here. But what is the correct way to check for null values in JSONValue? I can do is null or == null on the JSONValue, but that only works if the value is actually null or it's a type that converts to null. So, for instance, if I have a key-value pair in a JSON document where the value's type is supposed a bool, but it could be null, doing something like

auto value = key in json;
enforce(key !is null, "error msg");
if(*value is null)
{ do something }
else
{ do something else }

will work as long as the value is null but will result in an exception being thrown if the value is true or false. As far as I can tell, there is not "isNull" check or equivalent that I can do on JSONValue. So, what is the correct way to go about checking whether a JSONValue is null?

The generic way is to use value.kind == JSONValue.Kind.null_. But I
guess a convenience method really makes sense in this case. I'll add
isNull.