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

Problem encoding with UTF8 #33

Closed fabiostrocco closed 7 years ago

fabiostrocco commented 8 years ago

The following code fails

debugMsg = "→";
Dartson dson = new Dartson.JSON();
assert(dson.encode(debugMsg) != "{}");
kbirch commented 8 years ago

Bump on this issue please, I am running into it as well.

class BadEncode {
  String title;
  String subtitle;
}

BadEncode be = new BadEncode()
    ..title = "Passion: Salvation’s Tide Is Rising"
    ..subtitle = "Here is a subtitle";

Dartson dson = new Dartson.JSON();
String encoded = dson.encode(be);

print (encoded);

The output is this (title runtimeType is _InternalLinkedHashMap):

{"title":{},"subtitle":"Here is a subtitle"}

The issue is with the apostrophe character used in this example (’). If I change it to (') it works as expected.