flutter 用于扑翼镖的Map字符串

k2arahey  于 2023-02-25  发布在  Flutter
关注(0)|答案(1)|浏览(128)
{"ABB": {"23-Feb-2023": {"Script": 0, "instrumentType": "Stock Futures", "change": -15.8, "pChange": -0.5, "bidPrice": 3162.9, "bidqty": 500, "askPrice": 3168.1, "askqty": 250, "expiryDate": "23-Feb-2023", "LTT": "2023-02-21T15:30:03.411537"}}}

如何将此String转换为.dart文件的Map
我已经尝试了模型类,但得到错误.

6bc51xsx

6bc51xsx1#

在Dart中,使用jsonDecode获得Map

String json = '{"ABB": {"23-Feb-2023": {"Script": 0, "instrumentType": "Stock Futures", "change": -15.8, "pChange": -0.5, "bidPrice": 3162.9, "bidqty": 500, "askPrice": 3168.1, "askqty": 250, "expiryDate": "23-Feb-2023", "LTT": "2023-02-21T15:30:03.411537"}}}';
Map<String, dynamic> map = jsonDecode(json); 
print(map['ABB']['23-Feb-2023']['instrumentType']); // Stock Futures

相关问题