Skip to content

Commit

Permalink
Merge pull request #4176 from BBasile/issue-15884
Browse files Browse the repository at this point in the history
fix issue 15884 - Assigning char[] to std.json.JSONValue creates array, not string
  • Loading branch information
DmitryOlshansky committed Apr 11, 2016
2 parents 11f8935 + 329f068 commit ada161f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions std/json.d
Expand Up @@ -346,6 +346,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 @@ -1692,3 +1697,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 ada161f

Please sign in to comment.