I have been hacking with Dart for a few months, mostly Angular.dart. My apps are maturing: while focusing on processes I am writing Dart code generators.
Since we are the web platform, I deal with JSON often. It would be very useful if the Dart language supported JSON so that I could write Dart programs like:
main() {
String data = <cut-and-paste JSON from somewhere>;
print(data);
}
But, Dart is a new language, so JSON *could* be a subset of Dart. JSON is almost a double-quoted Dart string, except for Dart's '$' string interpolation.
Raw strings (r'string$') have string interpolation disabled. Yet, in practice, raw strings are useless since it is impossible to represent both single and double quotes in the same raw string.
There are two options for supporting JSON:
1. introduce a new string format j"json string"
2. change the spec for raw strings to allow escape characters. This would break the spec, but it would make Dart strings much more useful.
Thoughts?
Specifically for option (2), are there developers that are using raw strings and depend
on them not being escaped? I know, in Angular.dart, we use them in our test case names since we prepend a $ to some of our service names.
James deBoer