I have map like this: {"a": "2022-01-26T17:10:51", "b": "{$WWWWWW}", "c":"$$$.id=='TEXT'"}
As You see, inside code is a lot of "", $, '' {}
. How I can parse it? I could not save this string as map, there is some my tries:
Map m = {"a": "2022-01-26T17:10:51", "b": "{$WWWWWW}", "c":"$$$.id=='TEXT'"};
String s1 = r'{"a": "2022-01-26T17:10:51", "b": "{$WWWWWW}", "c":"$$$.id=='TEXT'"}';
String s2 = '{"a": "2022-01-26T17:10:51", "b": "{$WWWWWW}", "c":"$$$.id=='TEXT'"}';
String s3 = b'{"a": "2022-01-26T17:10:51", "b": "{$WWWWWW}", "c":"$$$.id=='TEXT'"}';
But none of these line can not pass compilation.
CodePudding user response:
When string started with r
and is surrounded by '''
every special characters inside is ignored:
import 'dart:convert';
void main() {
String s = r'''{"a": "2022-01-26T17:10:51", "b": "{$WWWWWW}", "c":"$$$.id=='TEXT'"}''';
Map r = jsonDecode(s);
for(var i in r.keys)
{
print(r[i]);
}
}