Skip to content

Commit

Permalink
Fix and test for JSONValue(true), JSONValue(false)
Browse files Browse the repository at this point in the history
  • Loading branch information
shoo committed Nov 25, 2013
1 parent ba31aeb commit 007302f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions std/json.d
Expand Up @@ -172,6 +172,10 @@ struct JSONValue
type_tag = JSON_TYPE.STRING;
store.str = arg;
}
else static if(is(Unqual!T == bool))
{
type_tag = arg ? JSON_TYPE.TRUE : JSON_TYPE.FALSE;
}
else static if(is(T : ulong) && isUnsigned!T)
{
type_tag = JSON_TYPE.UINTEGER;
Expand Down Expand Up @@ -217,10 +221,6 @@ struct JSONValue
store.array = new_arg;
}
}
else static if(is(T : bool))
{
type_tag = arg ? JSON_TYPE.TRUE : JSON_TYPE.FALSE;
}
else static if(is(T : JSONValue))
{
type_tag = arg.type;
Expand Down Expand Up @@ -888,6 +888,12 @@ unittest
jv.array = [JSONValue(1), JSONValue(2), JSONValue(3)];
assert(jv.type == JSON_TYPE.ARRAY);
assert(jv.array == [JSONValue(1), JSONValue(2), JSONValue(3)]);

jv = true;
assert(jv.type == JSON_TYPE.TRUE);

jv = false;
assert(jv.type == JSON_TYPE.FALSE);
}

unittest
Expand Down

0 comments on commit 007302f

Please sign in to comment.