Skip to content

Commit

Permalink
fix issue 15884 - Assigning char[] to std.json.JSONValue creates arra…
Browse files Browse the repository at this point in the history
…y, not string
  • Loading branch information
Basile Burg committed Apr 9, 2016
1 parent ef26d53 commit 329f068
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions std/json.d
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

0 comments on commit 329f068

Please sign in to comment.