这种嵌套的 JSON 无法生成正确的 Model 吗?

#6 · closed · 5 comments

View on GitHub ↗

angelen10

服务端返回的 JSON 如下: ```json { "code": 200, "msg": "ok", "data": { "list": [ { "id": 1, "pid": 0, "code": 110000, "name": "北京市" }, { "id": 8040, "pid": 5630, "code": 1093, "name": "崖城镇" }, { "id": 8041, "pid": 5630, "code": 1094, "name": "育才镇" }, { "id": 8064, "pid": 8050, "code": 1117, "name": "陵水黎族自治县" }, { "id": 8065, "pid": 8050, "code": 1118, "name": "保亭黎族苗族自治县" }, { "id": 8066, "pid": 8050, "code": 1119, "name": "琼中黎族苗族自治县" }, { "id": 8067, "pid": 5939, "code": 1120, "name": "经开区" }, { "id": 8081, "pid": 8077, "code": 1134, "name": "五家渠市" } ] } } ``` 错误如下: ![图片](https://ww4.sinaimg.cn/large/006tKfTcgy1fiv8qhljdlj31kw14dtlx.jpg)

Comments

nixzhu

Thanks for your test! I’ll investigate it later.

nixzhu

It’s a bug cause by an optimization for `list`. For a temporary solution, you can change the `list` to `list_` in JSON, after the generation, you change the model name back. I’ll fix it in a new release.

angelen10

Thank you for that. 😁

nixzhu

You can also use **Array Object Map** such as `list: Info` to avoid this issue.

angelen10

@nixzhu Thanks for your advice.