小编iDo*_*iDo的帖子

Flutter - 异常:类型“int”不是类型“double”的子类型

我在后台解析 JSON 时遇到了困难。我正在使用FoodData API

以下是对一道菜的响应示例:

{
"fdcId": 167782,
"description": "Abiyuch, raw",
"dataType": "SR Legacy",
"publicationDate": "2019-04-01",
"ndbNumber": "9427",
"foodNutrients": [
{
"number": "318",
"name": "Vitamin A, IU",
"amount": 100,
"unitName": "IU",
"derivationCode": "A",
"derivationDescription": "Analytical"
},
{
"number": "268",
"name": "Energy",
"amount": 290,
"unitName": "kJ",
"derivationCode": "NC",
"derivationDescription": "Calculated"
},
]
Run Code Online (Sandbox Code Playgroud)

我使用 JSON 到 DART 转换器并得到了这个输出 -

class FoodGen {
  int fdcId;
  String description;
  String dataType;
  String publicationDate;
  String ndbNumber;
  List<FoodNutrients> foodNutrients;

  FoodGen(
      {this.fdcId,
      this.description,
      this.dataType,
      this.publicationDate,
      this.ndbNumber, …
Run Code Online (Sandbox Code Playgroud)

string double json integer flutter

1
推荐指数
1
解决办法
3863
查看次数

标签 统计

double ×1

flutter ×1

integer ×1

json ×1

string ×1