如何将来自我的API的String数据解析为列表?

时间:2019-05-06 12:47:03

标签: json dart

我正在从数据库中以以下格式获取数据,我想将其转换为列表或类似内容以供进一步使用。

[  
   {  
      "id":6,
      "first_name":"Gigel",
      "last_name":"Ion0",
      "age":35,
      "detail":"Gigel is 35 old"
   },
   {  
      "id":7,
      "first_name":"Marius",
      "last_name":"John",
      "age":40,
      "detail":"Marius is 40 old"
   },
   {  
      "id":8,
      "first_name":"Cosmin",
      "last_name":"Lefter",
      "age":80,
      "detail":"Cosmin is 80 old"
   },
   {  
      "id":9,
      "first_name":"George",
      "last_name":"Calin",
      "age":65,
      "detail":"George is 65 old"
   }
]

我是飞镖的新手,仍然在学习操作方法,尝试不成功地对其进行解析。

1 个答案:

答案 0 :(得分:0)

您可以尝试以下操作:

import netCDF4
rootgrp = netCDF4.Dataset(5P_NRTI_L2__CO_____20190505T104819_20190505T105319_08073_01_010301_20190505T124936.nc, "r",format="NETCDF4")

dart json解析器将json数组映射到dart列表<>类型。有关更多详细信息,请参见here