wilinz / json5_model

A one-line command to convert a JSON file into a Dart model class.
https://pub.dev/packages/json5_model
MIT License
11 stars 1 forks source link

对于key为数字的怎么兼容? #1

Closed faimin closed 1 year ago

faimin commented 1 year ago
{
    "week_list": {
        "0": [
            {
              "isnew": 1,
              "id": 20230139,
              "wd": 0,
              "name": "堀与宫村 -piece-",
              "mtime": "2023-09-03 00:16:11",
              "namefornew": "00:00 第10集"
            }
        ],
        "1": [
            {
              "isnew": 1,
              "id": 20230139,
              "wd": 0,
              "name": "堀与宫村 -piece-",
              "mtime": "2023-09-03 00:16:11",
              "namefornew": "00:00 第10集"
            }
        ],
        "2": [
            {
              "isnew": 1,
              "id": 20230139,
              "wd": 0,
              "name": "堀与宫村 -piece-",
              "mtime": "2023-09-03 00:16:11",
              "namefornew": "00:00 第10集"
            }
        ],
    }
}
wilinz commented 1 year ago

目前可以手动改生成的代码,此库没有特殊处理

wilinz commented 1 year ago

如果是数组的话说明这个接口数据不规范,不应该用 key 作为 index,如果你没法修改后端接口,建议直接从 Map 中读取

faimin commented 1 year ago

改成自己手动解析了