import asdf;
struct S {
int[] values;
}
string s = serializeToJson(S([]));
assert(s == "{\"values\": []}");
The assertion above fails because ASDF interprets an empty array as null, when a user would reasonably expect that if they provide an empty array to be serialized, that it should be represented in JSON as an empty array.
This pull request removes that check for null arrays, which is safe because dynamic arrays are not null in dRuntime, in the sense that you can iterate and get length and other properties of empty arrays.
Consider the following example:
The assertion above fails because ASDF interprets an empty array as null, when a user would reasonably expect that if they provide an empty array to be serialized, that it should be represented in JSON as an empty array.
This pull request removes that check for null arrays, which is safe because dynamic arrays are not null in dRuntime, in the sense that you can iterate and get length and other properties of empty arrays.