String 如何在flatter中将JSON数据转换为映射?

String 如何在flatter中将JSON数据转换为映射?,string,firebase,flutter,dictionary,push-notification,String,Firebase,Flutter,Dictionary,Push Notification,我的JSON数据如下所示: { notification:{ title: flutter fcm, body: i got a firebase notification }, data:{ myKey: myValue } } 我应该如何将其转换为地图 这是打印在firebase推送通知的回调上的值。它正在我的控制台上打印。我想把它转换成地图。此JSON数据的运行时类型为字符串。我们可以使用dart:convert

我的JSON数据如下所示:

{
notification:{
     title: flutter fcm, 
     body: i got a firebase notification
              }, 
 data:{
     myKey: myValue
      }
}
我应该如何将其转换为地图


这是打印在firebase推送通知的回调上的值。它正在我的控制台上打印。我想把它转换成地图。此JSON数据的运行时类型为字符串。

我们可以使用
dart:convert
包和
JSON.decode
方法将
JSON
字符串转换为
映射

import 'dart:convert';

final Map<String, dynamic> jsonData = json.decode(jsonData);
导入'dart:convert';
最终映射jsonData=json.decode(jsonData);