Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
angelen10 opened this issue Aug 24, 2017 · 5 comments
Closed

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

angelen10 opened this issue Aug 24, 2017 · 5 comments

Comments

@angelen10
Copy link

服务端返回的 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": "五家渠市"
      }
    ]
  }
}

错误如下:
图片

@nixzhu
Copy link
Owner

nixzhu commented Aug 24, 2017

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

@nixzhu
Copy link
Owner

nixzhu commented Aug 24, 2017

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
Copy link
Author

Thank you for that. 😁

@nixzhu
Copy link
Owner

nixzhu commented Aug 25, 2017

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

@angelen10
Copy link
Author

@nixzhu Thanks for your advice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants