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

Code generate missing class #65

Open
1774575836 opened this issue Apr 29, 2021 · 0 comments
Open

Code generate missing class #65

1774575836 opened this issue Apr 29, 2021 · 0 comments

Comments

@1774575836
Copy link

Json:
{
"data": {
"PersonInfo": {
"name": "Eric"
},
"PersonInfoList": [
{
"name": "Eric"
}
]
}
}

Output:
class GQLResponse {
Data data;

GQLResponse({this.data});

GQLResponse.fromJson(Map<String, dynamic> json) {
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.data != null) {
data['data'] = this.data.toJson();
}
return data;
}
}

class Data {
PersonInfo personInfo;
List personInfoList;

Data({this.personInfo, this.personInfoList});

Data.fromJson(Map<String, dynamic> json) {
personInfo = json['PersonInfo'] != null
? new PersonInfo.fromJson(json['PersonInfo'])
: null;
if (json['PersonInfoList'] != null) {
personInfoList = new List();
json['PersonInfoList'].forEach((v) {
personInfoList.add(new PersonInfoList.fromJson(v));
});
}
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.personInfo != null) {
data['PersonInfo'] = this.personInfo.toJson();
}
if (this.personInfoList != null) {
data['PersonInfoList'] =
this.personInfoList.map((v) => v.toJson()).toList();
}
return data;
}
}

class PersonInfo {
String name;

PersonInfo({this.name});

PersonInfo.fromJson(Map<String, dynamic> json) {
name = json['name'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['name'] = this.name;
return data;
}
}

The class PersonInfoList is missing but used in generated code, thanks if you can fix this.

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

1 participant