Replace uses of JSON constant in intl and intl_translation
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=192172678
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5ad2863..82ec07e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
* Add type parameters on numberFormatSymbols for Dart 2 compatibility. Note
that it only adds them on the right-hand side because adding them to the
static type can cause unnecessary cast warnings.
+ * Replace uses of JSON constant for Dart 2 compatibility.
## 0.15.4
* A couple of minor Dart 2 fixes.
diff --git a/lib/src/lazy_locale_data.dart b/lib/src/lazy_locale_data.dart
index 07d46f7..b975a4e 100644
--- a/lib/src/lazy_locale_data.dart
+++ b/lib/src/lazy_locale_data.dart
@@ -35,6 +35,8 @@
/// The set of available locales.
Set availableLocaleSet;
+ static const jsonDecoder = const JsonCodec();
+
/// The constructor. The [_reader] specifies where the data comes
/// from. The [_creationFunction] creates the appropriate data type
/// from the remote data (which typically comes in as a Map). The
@@ -90,6 +92,6 @@
/// Given a Future [input] whose value is expected to be a string in JSON
/// form, return another future that parses the JSON into a usable format.
Future jsonData(Future input) {
- return input.then((response) => JSON.decode(response));
+ return input.then((response) => jsonDecoder.decode(response));
}
}
diff --git a/tool/generate_locale_data_files.dart b/tool/generate_locale_data_files.dart
index 2fde04b..498d405 100644
--- a/tool/generate_locale_data_files.dart
+++ b/tool/generate_locale_data_files.dart
@@ -67,10 +67,10 @@
void writePatterns(locale, patterns) {
var file = new File(path.join(dataDirectory, 'patterns', '${locale}.json'));
file.openWrite()
- ..write(JSON.encode(patterns))
+ ..write(new JsonCodec().encode(patterns))
..close();
}
void writeToJSON(dynamic data, IOSink out) {
- out.write(JSON.encode(data.serializeToMap()));
+ out.write(new JsonCodec().encode(data.serializeToMap()));
}