diff --git a/dub.selections.json b/dub.selections.json index 14bdc49..51dd18b 100644 --- a/dub.selections.json +++ b/dub.selections.json @@ -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" } diff --git a/source/handy_http_data/json.d b/source/handy_http_data/json.d index 4e172c0..6f0f8c7 100644 --- a/source/handy_http_data/json.d +++ b/source/handy_http_data/json.d @@ -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 {