Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tchaloupka committed May 14, 2017
1 parent 7278278 commit e5975db
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions data/vibe/data/json.d
Original file line number Diff line number Diff line change
Expand Up @@ -1949,6 +1949,12 @@ struct JsonStringSerializer(R, bool pretty = false)
unittest
{
assert(serializeToJsonString(double.nan) == "null");
assert(serializeToJsonString(Json()) == "null");
assert(serializeToJsonString(Json(["bar":Json("baz"),"foo":Json()])) == `{"bar":"baz","foo":null}`);

struct Foo{Json bar = Json();}
Foo f;
assert(serializeToJsonString(f) == `{"bar":null}`);
}

/**
Expand All @@ -1968,7 +1974,7 @@ void writeJsonString(R, bool pretty = false)(ref R dst, in Json json, size_t lev
@safe // if( isOutputRange!R && is(ElementEncodingType!R == char) )
{
final switch( json.type ){
case Json.Type.undefined: dst.put("undefined"); break;
case Json.Type.undefined: dst.put("null"); break;
case Json.Type.null_: dst.put("null"); break;
case Json.Type.bool_: dst.put(json.get!bool ? "true" : "false"); break;
case Json.Type.int_: formattedWrite(dst, "%d", json.get!long); break;
Expand Down Expand Up @@ -2010,7 +2016,6 @@ void writeJsonString(R, bool pretty = false)(ref R dst, in Json json, size_t lev
dst.put('{');
bool first = true;
foreach (string k, ref const Json e; json.byKeyValue) {
if( e.type == Json.Type.undefined ) continue;
if( !first ) dst.put(',');
first = false;
static if (pretty) {
Expand Down

0 comments on commit e5975db

Please sign in to comment.