【发布时间】:2019-10-01 05:28:57
【问题描述】:
我有一个 json 文件,如下所示。当用户选择金额和期限时,我需要显示一个期限值。
示例:如果用户选择金额=500,期限=24M。我需要显示数字 6。
如何在 Flutter 中过滤 Map?
这是我到目前为止所做的:
我的 json 文件:
{
“AMOUNT”:[
{
"500":{
“MATURITY":[
{
"12M”:”4”
},
{
"24M”:”6”
},
{
"36M”:”8”
},
{
"48M”:”10”
},
{
"60M”:”12”
}
]
},
“1000":{
“MATURITY":[
{
"12M”:”8”
},
{
"24M”:”12”
},
{
"36M”:”16”
},
{
"48M”:”20”
},
{
"60M”:”24”
}
]
}
}
]
}
Json 加载:
// Test part trying to load json into basic map...
String jsonFastMaturity = await rootBundle.loadString("assets/myfile.json");
Map _mapFastMaturity = jsonDecode(jsonFastMaturity);
List _tmpFastMaturity = _mapFastMaturity[“AMOUNT”];
【问题讨论】: