Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Unified Diff: lib/src/protobuf/json.dart

Issue 2612233003: Always serialize 64-bit integers as strings in JSON. (Closed)
Patch Set: Add test for JSON-coding of int64s Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/event_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/protobuf/json.dart
diff --git a/lib/src/protobuf/json.dart b/lib/src/protobuf/json.dart
index 5a7fb78202889f8c2822cad1023acb3f458b5d13..814f13a6e67a8642ce70ec517963a0ba8b8e6a55 100644
--- a/lib/src/protobuf/json.dart
+++ b/lib/src/protobuf/json.dart
@@ -4,10 +4,6 @@
part of protobuf;
-// Range of integers in JSON (53-bit integers).
-Int64 _MAX_JSON_INT = new Int64.fromInts(0x200000, 0);
-Int64 _MIN_JSON_INT = -_MAX_JSON_INT;
-
Map<String, dynamic> _writeToJsonMap(_FieldSet fs) {
convertToMap(fieldValue, fieldType) {
int baseType = PbFieldType._baseType(fieldType);
@@ -37,10 +33,6 @@ Map<String, dynamic> _writeToJsonMap(_FieldSet fs) {
case PbFieldType._UINT64_BIT:
case PbFieldType._FIXED64_BIT:
case PbFieldType._SFIXED64_BIT:
- // Use strings for 64-bit integers which cannot fit in doubles.
- if (_MIN_JSON_INT <= fieldValue && fieldValue <= _MAX_JSON_INT) {
- return fieldValue.toInt();
- }
return fieldValue.toString();
case PbFieldType._GROUP_BIT:
case PbFieldType._MESSAGE_BIT:
« no previous file with comments | « no previous file | test/event_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698