Fixed static if

This commit is contained in:
Andrew Lalis 2025-07-25 14:44:39 -04:00
parent 98d379925e
commit 003a51a177
2 changed files with 10 additions and 5 deletions

View File

@ -3,9 +3,9 @@
"versions": {
"asdf": "0.7.17",
"dxml": "0.4.4",
"handy-http-primitives": "1.6.0",
"mir-algorithm": "3.22.3",
"mir-core": "1.7.1",
"handy-http-primitives": "1.8.0",
"mir-algorithm": "3.22.4",
"mir-core": "1.7.3",
"silly": "1.1.1",
"streams": "3.6.0"
}

View File

@ -56,8 +56,13 @@ void writeJsonBody(T)(ref ServerHttpResponse response, in T bodyContent) {
import std.json;
import asdf : serializeToJson, SerdeException;
try {
static if (isArray!T && bodyContent.length == 0) {
string responseBody = "[]";
static if (isArray!T) {
string responseBody;
if (bodyContent.length == 0) {
responseBody = "[]";
} else {
responseBody = serializeToJson(bodyContent);
}
} else static if (is(T == JSONValue)) {
string responseBody = bodyContent.toString();
} else {