Skip to content

Commit

Permalink
std_data_json: fix enum key'd arrays with fewer members than enum values
Browse files Browse the repository at this point in the history
  • Loading branch information
Herringway committed May 30, 2024
1 parent 29c34fe commit c0b21a5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion std_data_json/source/siryul/std_data_json.d
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,13 @@ struct StdDataJSON {
return Node(value[index]);
}
size_t length() const @safe {
return value.get!(JSONValue[]).length;
if (value.hasType!(JSONValue[])) {
return value.get!(JSONValue[]).length;
} else if (value.hasType!(JSONValue[string])) {
return value.get!(JSONValue[string]).length;
} else {
throw new DeserializeException("Node has no length", getMark());
}
}
bool opBinaryRight(string op : "in")(string key) {
return !!(key in value);
Expand Down

0 comments on commit c0b21a5

Please sign in to comment.