Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support ulong values for Json #1118

Merged
merged 1 commit into from
Jun 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1603,6 +1603,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 @@ -1625,6 +1626,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