diff --git a/std/json.d b/std/json.d index 7fd3fbf31b9..79485f6d311 100644 --- a/std/json.d +++ b/std/json.d @@ -344,6 +344,11 @@ struct JSONValue type_tag = JSON_TYPE.STRING; store.str = arg; } + else static if(is(T : char[])) + { + type_tag = JSON_TYPE.STRING; + store.str = arg.idup; + } else static if(is(T : bool)) { type_tag = arg ? JSON_TYPE.TRUE : JSON_TYPE.FALSE; @@ -1675,3 +1680,10 @@ pure nothrow @safe @nogc unittest testVal = null; assert(testVal.isNull); } + +pure nothrow @safe unittest // issue 15884 +{ + char[] str = "a".dup; + JSONValue testVal = str; + assert(testVal.type == JSON_TYPE.STRING); +}