Skip to content

Commit

Permalink
replace newlines when serializing text
Browse files Browse the repository at this point in the history
fix #5
Newline characters within a String value resulted in a JSON
decoding error.
  • Loading branch information
robert-virkus committed Apr 27, 2021
1 parent 89b53f9 commit c209f30
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/src/serializable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class Serializer {
if (value == null) {
buffer.write('null');
} else if (value is String) {
final text = value.replaceAll('"', r'\"');
final text = value.replaceAll('"', r'\"').replaceAll('\n', '\\n');
buffer..write('"')..write(text)..write('"');
} else if (value is int) {
buffer.write(value);
Expand Down

0 comments on commit c209f30

Please sign in to comment.