Remove usage of dart:json.
R=jmesserly@google.com, lrn@google.com, nweiz@google.com, rnystrom@google.com
Review URL: https://codereview.chromium.org//23596007
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_maps@26789 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/lib/builder.dart b/lib/builder.dart
index be00c9e..12587cd 100644
--- a/lib/builder.dart
+++ b/lib/builder.dart
@@ -7,8 +7,8 @@
// TODO(sigmund): add a builder for multi-section mappings.
-import 'dart:json' as json;
import 'dart:collection';
+import 'dart:convert';
import 'span.dart';
import 'src/vlq.dart';
@@ -108,7 +108,7 @@
}
/// Encodes all mappings added to this builder as a json string.
- String toJson(String fileUrl) => json.stringify(build(fileUrl));
+ String toJson(String fileUrl) => JSON.encode(build(fileUrl));
/// Get the index of [value] in [map], or create one if it doesn't exist.
int _indexOf(Map<String, int> map, String value) {
diff --git a/lib/parser.dart b/lib/parser.dart
index e293263..6b8bf37 100644
--- a/lib/parser.dart
+++ b/lib/parser.dart
@@ -5,7 +5,7 @@
/// Contains the top-level function to parse source maps version 3.
library source_maps.parser;
-import 'dart:json' as json;
+import 'dart:convert';
import 'span.dart';
import 'src/utils.dart';
@@ -15,7 +15,7 @@
// TODO(sigmund): evaluate whether other maps should have the json parsed, or
// the string represenation.
Mapping parse(String jsonMap, {Map<String, Map> otherMaps}) =>
- parseJson(json.parse(jsonMap), otherMaps: otherMaps);
+ parseJson(JSON.decode(jsonMap), otherMaps: otherMaps);
/// Parses a source map directly from a json map object.
Mapping parseJson(Map map, {Map<String, Map> otherMaps}) {
diff --git a/test/builder_test.dart b/test/builder_test.dart
index 7bf2ee4..8842c62 100644
--- a/test/builder_test.dart
+++ b/test/builder_test.dart
@@ -4,7 +4,7 @@
library test.source_maps_test;
-import 'dart:json' as json;
+import 'dart:convert';
import 'package:unittest/unittest.dart';
import 'package:source_maps/source_maps.dart';
import 'common.dart';
@@ -27,6 +27,6 @@
..addLocation(inputVar2.start, outputVar2.start, 'longVar2')
..addLocation(inputExpr.start, outputExpr.start, null))
.toJson(output.url);
- expect(str, json.stringify(EXPECTED_MAP));
+ expect(str, JSON.encode(EXPECTED_MAP));
});
}
diff --git a/test/parser_test.dart b/test/parser_test.dart
index 1c32cbd..c99acb2 100644
--- a/test/parser_test.dart
+++ b/test/parser_test.dart
@@ -4,7 +4,7 @@
library test.parser_test;
-import 'dart:json' as json;
+import 'dart:convert';
import 'package:unittest/unittest.dart';
import 'package:source_maps/source_maps.dart';
import 'common.dart';
@@ -19,7 +19,7 @@
});
test('parse + json', () {
- var mapping = parse(json.stringify(EXPECTED_MAP));
+ var mapping = parse(JSON.encode(EXPECTED_MAP));
check(outputVar1, mapping, inputVar1, false);
check(outputVar2, mapping, inputVar2, false);
check(outputFunction, mapping, inputFunction, false);
diff --git a/test/printer_test.dart b/test/printer_test.dart
index eaeae2a..fe27f76 100644
--- a/test/printer_test.dart
+++ b/test/printer_test.dart
@@ -4,7 +4,7 @@
library test.printer_test;
-import 'dart:json' as json;
+import 'dart:convert';
import 'package:unittest/unittest.dart';
import 'package:source_maps/printer.dart';
import 'package:source_maps/span.dart';
@@ -23,7 +23,7 @@
..mark(inputExpr)
..add('x + y;\n');
expect(printer.text, OUTPUT);
- expect(printer.map, json.stringify(EXPECTED_MAP));
+ expect(printer.map, JSON.encode(EXPECTED_MAP));
});
test('printer projecting marks', () {
@@ -90,7 +90,7 @@
..add('x + y;\n', span: inputExpr)
..build('output.dart');
expect(printer.text, OUTPUT);
- expect(printer.map, json.stringify(EXPECTED_MAP));
+ expect(printer.map, JSON.encode(EXPECTED_MAP));
});
test('nested use', () {
@@ -102,7 +102,7 @@
..add('x + y;\n', span: inputExpr)
..build('output.dart');
expect(printer.text, OUTPUT);
- expect(printer.map, json.stringify(EXPECTED_MAP));
+ expect(printer.map, JSON.encode(EXPECTED_MAP));
});
test('add indentation', () {