Browse Source

Fixed nested List fromJson

master
Kenneth Bruen 3 years ago
parent
commit
0a7c0bfa54
Signed by: kbruen
GPG Key ID: C1980A470C3EE5B1
  1. 4
      bin/tdlib_gen.dart

4
bin/tdlib_gen.dart

@ -174,6 +174,7 @@ String findFromJsonHandling(
String functionPrefix = 'f.', String functionPrefix = 'f.',
String? varNameInsteadOfKeyName} String? varNameInsteadOfKeyName}
) { ) {
final varAccess = varNameInsteadOfKeyName ?? "json['$keyName']";
if (type.startsWith('vector<')) { if (type.startsWith('vector<')) {
final tmp1 = type.replaceFirst('vector<', ''); final tmp1 = type.replaceFirst('vector<', '');
final tmp2 = tmp1.substring(0, tmp1.length - 1); final tmp2 = tmp1.substring(0, tmp1.length - 1);
@ -187,10 +188,9 @@ String findFromJsonHandling(
objectPrefix: objectPrefix, objectPrefix: objectPrefix,
varNameInsteadOfKeyName: 'e', varNameInsteadOfKeyName: 'e',
); );
return "(json['$keyName'] as List<dynamic>).map((e) => ($innerHandler)).toList(growable: false)"; return '($varAccess as List<dynamic>).map((e) => ($innerHandler)).toList(growable: false)';
} }
final varAccess = varNameInsteadOfKeyName ?? "json['$keyName']";
final predefined = { final predefined = {
'double': 'double', 'double': 'double',
'string': 'String', 'string': 'String',

Loading…
Cancel
Save