Skip to content

Commit

Permalink
Merge pull request #1118 from IgorStepanov/ulong-json
Browse files Browse the repository at this point in the history
support ulong values for Json
  • Loading branch information
s-ludwig committed Jun 3, 2015
2 parents 4070d06 + 5a3224b commit 309ea82
Show file tree
Hide file tree
Showing 4 changed files with 288 additions and 49 deletions.
5 changes: 5 additions & 0 deletions examples/json/source/app.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import vibe.data.json;

import std.stdio;
import std.bigint;

void main()
{
Expand All @@ -17,4 +18,8 @@ void main()
Json parent = obj;
parent.remove("item1");
foreach (i; obj) writeln(i);

auto obj2 = parseJsonString(`{"serial":17559991181826658461}`);
writeln("serial: ", obj2["serial"]);
assert(obj2["serial"] == BigInt(17559991181826658461UL));
}
4 changes: 4 additions & 0 deletions source/vibe/data/bson.d
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,7 @@ private Bson.Type jsonTypeToBsonType(Json.Type tp)
Bson.Type.null_,
Bson.Type.bool_,
Bson.Type.long_,
Bson.Type.long_,
Bson.Type.double_,
Bson.Type.string,
Bson.Type.array,
Expand All @@ -1626,6 +1627,9 @@ private Bson.Type writeBson(R)(ref R dst, in Json value)
case Json.Type.int_:
dst.put(toBsonData(cast(long)value));
return Bson.Type.long_;
case Json.Type.bigint:
dst.put(toBsonData(cast(long)value));
return Bson.Type.long_;
case Json.Type.float_:
dst.put(toBsonData(cast(double)value));
return Bson.Type.double_;
Expand Down
Loading

0 comments on commit 309ea82

Please sign in to comment.