eredo / dartson

Dartson is a Dart library that can be used to convert Dart objects into a JSON string.
MIT License
79 stars 29 forks source link

serializing doubles fails #26

Closed rightisleft closed 9 years ago

rightisleft commented 9 years ago

Example Code: https://github.com/rightisleft/dartson_double

I'm building up a DTO that accepts a double for a value. When serializing from dart, i get the following error:

/usr/local/Cellar/dart/1.10.1/libexec/bin/dart --ignore-unrecognized-flags --checked --package-root=/Users/jmurphy/projects/dartson_double/packages --enable-vm-service:50734 --trace_service_pause_events /Users/jmurphy/projects/dartson_double/bin/main.dart
Observatory listening on http://127.0.0.1:50734
Unhandled exception:
Stack Overflow
#0      StringBuffer.write (dart:core-patch/string_buffer_patch.dart:57)
#1      StringBuffer.StringBuffer (dart:core-patch/string_buffer_patch.dart:52)
#2      MirrorSystem.getName (dart:mirrors-patch/mirrors_patch.dart:63)
#3      Dartson._serializeObject (package:dartson/dartson.dart:47:21)
#4      Dartson._setField (package:dartson/dartson.dart:78:14)
#5      Dartson._serializeObject.<anonymous closure> (package:dartson/dartson.dart:121:11)
#6      _CompactLinkedHashMap.forEach (dart:collection-patch/compact_hash.dart)
#7      Dartson._serializeObject (package:dartson/dartson.dart:149:35)
#8      Dartson._setField (package:dartson/dartson.dart:78:14)
#9      Dartson._serializeObject.<anonymous closure> (package:dartson/dartson.dart:121:11)
#10     _CompactLinkedHashMap.forEach (dart:collection-patch/compact_hash.dart)
#11     Dartson._serializeObject (package:dartson/dartson.dart:149:35)
#12     Dartson._setField (package:dartson/dartson.dart:78:14)
#13     Dartson._serializeObject.<anonymous closure> (package:dartson/dartson.dart:121:11)
...
...
#14     MapView.forEach (dart:collection/maps.dart:194)
#15     Dartson._serializeObject (package:dartson/dartson.dart:117:35)
#16     Dartson.serialize (package:dartson/dartson.dart:78:14)
#17     Dartson._serializeList.<anonymous closure> (package:dartson/dartson.dart:96:30)
#18     MappedListIterable.elementAt (dart:_internal/iterable.dart:413)
#19     ListIterable.toList (dart:_internal/iterable.dart:219)
#20     Dartson._serializeList (package:dartson/dartson.dart:96:44)
#21     Dartson.serialize (package:dartson/dartson.dart:72:14)
#22     main (file:///Users/jmurphy/projects/dartson_double/bin/main.dart:13:33)
#23     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:255)
#24     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.d

Process finished with exit code 255
rightisleft commented 9 years ago

patch works like a charm! might want to update supported types of the readme file - i assumed double would be supported :(

giolaq commented 9 years ago

Serializing doubles fails again @eredo

eredo commented 9 years ago

@joaobiriba I saw your post on stackoverflow and took a look at your code. There's an issue with using doubles in properties which type is defined as "num". I opened an issue #27

If possible please use the "double" type as long as the bug isn't fixed.