json2dart-generator 0.0.1 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ### 介绍
4
4
 
5
- JSON 转 Dart Model 类,提取文件夹中的 json 文件转换后导出对应的 dart 文件
5
+ JSON 转 Dart Model 类,将文件夹中的 json 文件转换为 Dart 对象并导出到指定目录
6
6
 
7
7
  ### 安装
8
8
 
@@ -16,16 +16,36 @@ npm install json2dart-generator -g
16
16
  json2dart options
17
17
 
18
18
  Options:
19
- -d, --dir <dir> json文件夹路径
20
- -e, --excludes <value...> 需要排除的文件,可指定多个
21
- -o, --output <file> 输出序列化模型路径, 默认 lib/models
22
- --nullsafety 启用空安全
19
+ -d, --dir <dir> json文件夹路径,默认 json_models
20
+ -o, --output <dir> dart模型输出路径,默认 lib/models
21
+ -s, --suffix <value> 自定义dart模型类名后缀,如 Entity
22
+ -e, --excludes <value...> 需要排除的json文件,可指定多个文件
23
+ --numparse 是否使用num处理数字类型
24
+ --nullsafety 是否启用空安全
25
+ ```
26
+
27
+ - 备注:
28
+ - 根类名为`json`的文件名(首字母自动转为大写,并且蛇形自动转驼峰)。
29
+ - 类的属性名自动蛇形转驼峰,当属性名为`dart关键字`时将在名称前面加`the`。
30
+ - 当`json`的值类型不存在或空时,自动默认处理为`String`类型并控制台输出警告。
31
+
32
+ - 帮助文档
33
+
34
+ ```bash
35
+ json2dart --help
36
+ ```
37
+
38
+ - 执行命令
39
+
40
+ ```bash
41
+ json2dart --dir ./json_models -o lib/models --nullsafety
23
42
  ```
24
43
 
25
44
  ### 示例
26
45
 
46
+ - test.json
47
+
27
48
  ```json
28
- // commonLang.json
29
49
  {
30
50
  "id": "467366309705273344",
31
51
  "parentId": "0",
@@ -45,16 +65,18 @@ Options:
45
65
  }
46
66
  ```
47
67
 
68
+ - test.dart
69
+
48
70
  ```dart
49
- class CommonLang {
71
+ class Test {
50
72
  String? id;
51
73
  String? parentId;
52
74
  String? name;
53
75
  String? value;
54
76
  List<String?>? codes;
55
- CommonLangData? data;
77
+ TestData? data;
56
78
 
57
- CommonLang({
79
+ Test({
58
80
  this.id,
59
81
  this.parentId,
60
82
  this.name,
@@ -62,25 +84,25 @@ class CommonLang {
62
84
  this.codes,
63
85
  this.data,
64
86
  });
65
- CommonLang.fromJson(Map<String, dynamic> json) {
87
+ Test.fromJson(Map<String, dynamic> json) {
66
88
  id = json['id']?.toString();
67
89
  parentId = json['parentId']?.toString();
68
90
  name = json['name']?.toString();
69
91
  value = json['value']?.toString();
70
- codes = List<String>.from(json['codes'] ?? []);
71
- data = json['data'] != null ? CommonLangData.fromJson(json['data']) : null;
92
+ codes = (json['codes'] != null && json['codes'] is List) ? json['codes'].map((e) => e?.toString())?.toList() : null;
93
+ data = (json['data'] != null && json['data'] is Map<String, dynamic>) ? TestData.fromJson(json['data']) : null;
72
94
  }
73
95
  Map<String, dynamic> toJson() => {
74
96
  'id': id,
75
97
  'parentId': parentId,
76
98
  'name': name,
77
99
  'value': value,
78
- 'codes': codes,
100
+ 'codes': codes?.map((e) => e)?.toList(),
79
101
  'data': data?.toJson(),
80
102
  };
81
103
  }
82
104
 
83
- class CommonLangData {
105
+ class TestData {
84
106
  String? dicCode;
85
107
  String? defaultValue;
86
108
  String? groupId;
@@ -90,7 +112,7 @@ class CommonLangData {
90
112
  int? showOrder;
91
113
  String? dicName;
92
114
 
93
- CommonLangData({
115
+ TestData({
94
116
  this.dicCode,
95
117
  this.defaultValue,
96
118
  this.groupId,
@@ -100,7 +122,7 @@ class CommonLangData {
100
122
  this.showOrder,
101
123
  this.dicName,
102
124
  });
103
- CommonLangData.fromJson(Map<String, dynamic> json) {
125
+ TestData.fromJson(Map<String, dynamic> json) {
104
126
  dicCode = json['dicCode']?.toString();
105
127
  defaultValue = json['defaultValue']?.toString();
106
128
  groupId = json['groupId']?.toString();
@@ -122,5 +144,4 @@ class CommonLangData {
122
144
  };
123
145
  }
124
146
 
125
-
126
147
  ```
@@ -1 +1 @@
1
- 'use strict';function a0_0x4a61(_0x2e9eee,_0x1b2013){const _0x5cd4c0=a0_0x5cd4();return a0_0x4a61=function(_0x4a61bb,_0x50a5cc){_0x4a61bb=_0x4a61bb-0x127;let _0x33ccd9=_0x5cd4c0[_0x4a61bb];return _0x33ccd9;},a0_0x4a61(_0x2e9eee,_0x1b2013);}const a0_0x12dbfc=a0_0x4a61;(function(_0x3bb3eb,_0x151060){const _0x1bc9a4=a0_0x4a61,_0x53d323=_0x3bb3eb();while(!![]){try{const _0x577928=-parseInt(_0x1bc9a4(0x134))/0x1+-parseInt(_0x1bc9a4(0x14a))/0x2+parseInt(_0x1bc9a4(0x16b))/0x3*(parseInt(_0x1bc9a4(0x15d))/0x4)+-parseInt(_0x1bc9a4(0x12e))/0x5*(-parseInt(_0x1bc9a4(0x158))/0x6)+parseInt(_0x1bc9a4(0x130))/0x7*(parseInt(_0x1bc9a4(0x16f))/0x8)+parseInt(_0x1bc9a4(0x17a))/0x9+-parseInt(_0x1bc9a4(0x14e))/0xa*(-parseInt(_0x1bc9a4(0x160))/0xb);if(_0x577928===_0x151060)break;else _0x53d323['push'](_0x53d323['shift']());}catch(_0x2246a0){_0x53d323['push'](_0x53d323['shift']());}}}(a0_0x5cd4,0x6a07c));Object['defineProperty'](exports,a0_0x12dbfc(0x164),{'value':!![]}),exports[a0_0x12dbfc(0x142)]=jsonToDart;function a0_0x5cd4(){const _0x18f402=['3095496rBXsjx','else','extends','\x20\x20Map<String,\x20dynamic>\x20toJson()\x20=>\x20{\x0a','\x20\x20\x20\x20','super','uppercaseFirst',')?.toList()','test','includes','Function','isArray','?.map((e)\x20=>\x20','catch','?.toString()','deferred','yield','static','bool','return','5rjfuVv','default','28qpenXF','rethrow','show','continue','522763DOrEUZ','isBoolean','new','interface','\x20\x20}','\x20as\x20List<dynamic>)?.map((e)\x20=>\x20',')\x20:\x20null','async','?.toJson()','void','WARNING\x20:\x20','isNumber','\x20)?.toList()','try','jsonToDart','int','factory','.fromJson(Map<String,\x20dynamic>\x20json)\x20{\x0a','typedef','\x20!=\x20null\x20?\x20','({\x0a','break','29958pqSpps','library','class','?.toString()\x20??\x20\x27\x27)','31830JzzYLr','isString','const','js-utils-plus','with','json[','assert','await','\x20\x20\x20\x20\x20\x20\x20\x20','snakeToCamel','882192XXkmMS','push','num','log','switch','2404vHddpy','join','while','957ZXhuoM','case','\x20has\x20Property\x20is\x20null,which\x20will\x20be\x20treated\x20as\x20String\x20type','\x20\x20});','__esModule','>.from(','class\x20','true','String','false','final','951CkHVry','mixin','double.tryParse(','double','27256OuRGti','sync','null','for','entries','implements','var','finally','set','List<','enum'];a0_0x5cd4=function(){return _0x18f402;};return a0_0x5cd4();}const js_utils_plus_1=require(a0_0x12dbfc(0x151));function modelTypeGenerator(_0x1ae679,_0x5276d4,_0x40707d){const _0x4e6841=a0_0x12dbfc;if((0x0,js_utils_plus_1[_0x4e6841(0x135)])(_0x1ae679))return{'type':_0x4e6841(0x12c),'typeTo':_0x11ee79=>_0x11ee79,'typeFrom':_0x1b754d=>''+_0x1b754d};if((0x0,js_utils_plus_1[_0x4e6841(0x14f)])(_0x1ae679))return{'type':_0x4e6841(0x168),'typeTo':_0x53dfb4=>_0x53dfb4,'typeFrom':_0x41cca0=>_0x41cca0+_0x4e6841(0x128)};if((0x0,js_utils_plus_1[_0x4e6841(0x13f)])(_0x1ae679))return(0x0,js_utils_plus_1['isInt'])(_0x1ae679)?{'type':_0x4e6841(0x143),'typeTo':_0x5d64d3=>_0x5d64d3,'typeFrom':_0x5ee4c7=>'int.tryParse('+_0x5ee4c7+_0x4e6841(0x14d)}:{'type':_0x4e6841(0x16e),'typeTo':_0x1a6304=>_0x1a6304,'typeFrom':_0x15bac5=>_0x4e6841(0x16d)+_0x15bac5+_0x4e6841(0x14d)};if((0x0,js_utils_plus_1['isObject'])(_0x1ae679))return{'type':_0x5276d4,'typeTo':_0x543be9=>_0x543be9+_0x4e6841(0x13c),'typeFrom':_0x4972f4=>_0x4972f4+_0x4e6841(0x147)+_0x5276d4+'.fromJson('+_0x4972f4+_0x4e6841(0x13a),'subLines':jsonToDart(_0x1ae679,_0x5276d4,_0x40707d)};if((0x0,js_utils_plus_1[_0x4e6841(0x185)])(_0x1ae679)){const _0x1f3fef=_0x1ae679[0x0];if(!_0x1f3fef)console[_0x4e6841(0x15b)](_0x4e6841(0x13e)+_0x5276d4+'\x20has\x20Property\x20is\x20null,which\x20will\x20be\x20treated\x20as\x20String\x20type');const {type:_0x1c8988,typeTo:_0x4918b1,typeFrom:_0x3a5e23,subLines:_0x3d80a2}=modelTypeGenerator(_0x1f3fef||'',_0x5276d4,_0x40707d);if([_0x4e6841(0x12c),'String','int',_0x4e6841(0x16e)]['includes'](_0x1c8988))return{'type':'List<'+_0x1c8988+(_0x40707d?'?':'')+'>','typeTo':_0x23d337=>_0x23d337,'typeFrom':_0x51fbc0=>_0x4e6841(0x178)+_0x1c8988+_0x4e6841(0x165)+_0x51fbc0+'\x20??\x20[])'};return{'type':_0x4e6841(0x178)+_0x1c8988+(_0x40707d?'?':'')+'>','typeTo':_0x523078=>_0x523078+_0x4e6841(0x186)+_0x4918b1('e')+_0x4e6841(0x181),'typeFrom':_0x339073=>'('+_0x339073+_0x4e6841(0x139)+_0x3a5e23('e')+_0x4e6841(0x140),'subLines':_0x3d80a2};}return console[_0x4e6841(0x15b)](_0x4e6841(0x13e)+_0x5276d4+_0x4e6841(0x162)),{'type':_0x4e6841(0x168),'typeTo':_0x1acf11=>_0x1acf11,'typeFrom':_0x4ec155=>_0x4ec155+_0x4e6841(0x128)};}function modelKeywordDefence(_0x4544aa){const _0x2b1963=a0_0x12dbfc;let _0x3692c7=[_0x2b1963(0x15a),'double',_0x2b1963(0x143),_0x2b1963(0x168),'bool','List','abstract','dynamic',_0x2b1963(0x174),_0x2b1963(0x132),'as',_0x2b1963(0x17b),'import',_0x2b1963(0x12b),_0x2b1963(0x154),_0x2b1963(0x179),'in',_0x2b1963(0x17f),_0x2b1963(0x13b),'export',_0x2b1963(0x137),_0x2b1963(0x15c),_0x2b1963(0x155),_0x2b1963(0x17c),'is',_0x2b1963(0x170),_0x2b1963(0x149),'external',_0x2b1963(0x14b),'this',_0x2b1963(0x161),_0x2b1963(0x144),_0x2b1963(0x16c),'throw',_0x2b1963(0x127),_0x2b1963(0x169),_0x2b1963(0x136),_0x2b1963(0x167),_0x2b1963(0x14c),_0x2b1963(0x16a),_0x2b1963(0x171),_0x2b1963(0x141),_0x2b1963(0x150),_0x2b1963(0x176),'on',_0x2b1963(0x146),_0x2b1963(0x133),_0x2b1963(0x172),'operator',_0x2b1963(0x175),'covariant',_0x2b1963(0x184),'part',_0x2b1963(0x13d),_0x2b1963(0x12f),'get',_0x2b1963(0x131),_0x2b1963(0x15f),_0x2b1963(0x129),'hide',_0x2b1963(0x12d),_0x2b1963(0x152),'do','if',_0x2b1963(0x177),_0x2b1963(0x12a)];if(_0x3692c7[_0x2b1963(0x183)](_0x4544aa)||/^\d/[_0x2b1963(0x182)](_0x4544aa))return'the'+(0x0,js_utils_plus_1['uppercaseFirst'])(_0x4544aa);return(0x0,js_utils_plus_1['snakeToCamel'])(_0x4544aa);}function jsonToDart(_0x1f298b,_0xe8d6fd,_0x5488a6){const _0x3edef0=a0_0x12dbfc;_0xe8d6fd=(0x0,js_utils_plus_1[_0x3edef0(0x180)])((0x0,js_utils_plus_1[_0x3edef0(0x157)])(_0xe8d6fd));let _0x5220ed=[],_0x1b0127=[],_0x5903df=[],_0x49731a=[],_0x4b02bc=[],_0x497793=[];_0x5220ed[_0x3edef0(0x159)](_0x3edef0(0x166)+_0xe8d6fd+'\x20{'),_0x5903df[_0x3edef0(0x159)]('\x20\x20'+_0xe8d6fd+_0x3edef0(0x148)),_0x49731a['push']('\x20\x20'+_0xe8d6fd+_0x3edef0(0x145)),_0x4b02bc[_0x3edef0(0x159)](_0x3edef0(0x17d));for(const [_0x5576c8,_0x19fcfc]of Object[_0x3edef0(0x173)](_0x1f298b)){let _0x395eb7='\x27'+_0x5576c8+'\x27',_0x1ef5fc=modelKeywordDefence(_0x5576c8);const _0x5ebaca=''+_0xe8d6fd+(0x0,js_utils_plus_1[_0x3edef0(0x180)])((0x0,js_utils_plus_1[_0x3edef0(0x157)])(_0x5576c8)),{type:_0x352abf,typeTo:_0x372307,typeFrom:_0x45fb4f,subLines:_0x538098}=modelTypeGenerator(_0x19fcfc,_0x5ebaca,_0x5488a6);if(_0x538098)_0x497793['push'](_0x538098);_0x5903df['push']('\x20\x20\x20\x20this.'+_0x1ef5fc+',\x0a'),_0x1b0127['push']('\x20\x20'+_0x352abf+(_0x5488a6?'?':'')+'\x20'+_0x1ef5fc+';\x0a'),_0x49731a['push'](_0x3edef0(0x17e)+_0x1ef5fc+'\x20=\x20'+_0x45fb4f(_0x3edef0(0x153)+_0x395eb7+']')+';\x0a'),_0x4b02bc[_0x3edef0(0x159)](_0x3edef0(0x156)+_0x395eb7+':\x20'+_0x372307(_0x1ef5fc)+',\x0a');}return _0x5903df['push'](_0x3edef0(0x163)),_0x49731a['push'](_0x3edef0(0x138)),_0x4b02bc[_0x3edef0(0x159)]('\x20\x20\x20\x20\x20\x20};'),_0x5220ed[_0x3edef0(0x159)](_0x1b0127[_0x3edef0(0x15e)]('')),_0x5220ed[_0x3edef0(0x159)](_0x5903df['join']('')),_0x5220ed[_0x3edef0(0x159)](_0x49731a['join']('')),_0x5220ed[_0x3edef0(0x159)](_0x4b02bc[_0x3edef0(0x15e)]('')),_0x5220ed[_0x3edef0(0x159)]('}\x0a'),_0x5220ed[_0x3edef0(0x159)](_0x497793[_0x3edef0(0x15e)]('')),_0x5220ed[_0x3edef0(0x15e)]('\x0d\x0a');}
1
+ 'use strict';const a0_0x52467b=a0_0x4acb;(function(_0x1c83f7,_0x1e4c55){const _0x3ff0b9=a0_0x4acb,_0xc11cc2=_0x1c83f7();while(!![]){try{const _0x86e999=-parseInt(_0x3ff0b9(0x161))/0x1+-parseInt(_0x3ff0b9(0x14f))/0x2*(-parseInt(_0x3ff0b9(0x152))/0x3)+-parseInt(_0x3ff0b9(0x126))/0x4+-parseInt(_0x3ff0b9(0x147))/0x5*(parseInt(_0x3ff0b9(0x14e))/0x6)+parseInt(_0x3ff0b9(0x159))/0x7+-parseInt(_0x3ff0b9(0x15e))/0x8+-parseInt(_0x3ff0b9(0x148))/0x9*(-parseInt(_0x3ff0b9(0x104))/0xa);if(_0x86e999===_0x1e4c55)break;else _0xc11cc2['push'](_0xc11cc2['shift']());}catch(_0x39b040){_0xc11cc2['push'](_0xc11cc2['shift']());}}}(a0_0x4cee,0x986fd));function a0_0x4acb(_0x5db2ce,_0x493dc5){const _0x4cee00=a0_0x4cee();return a0_0x4acb=function(_0x4acb32,_0x2de336){_0x4acb32=_0x4acb32-0x100;let _0x4b0c69=_0x4cee00[_0x4acb32];return _0x4b0c69;},a0_0x4acb(_0x5db2ce,_0x493dc5);}Object[a0_0x52467b(0x13b)](exports,a0_0x52467b(0x128),{'value':!![]}),exports['jsonToDart']=jsonToDart;const js_utils_plus_1=require('js-utils-plus');function a0_0x4cee(){const _0x538fa8=['push','int.tryParse(',')?.toList()','library','\x20is\x20List)\x20?\x20','get','json[','-\x20警告!:','uppercaseFirst','import','sync','false','?.toJson()','try','defineProperty','set','?.map((e)\x20=>\x20','typedef','continue','rethrow','break','while','class','switch','new','\x20\x20}','50UbCflv','27zzESxS','default','double','isArray','dynamic','case','630162Xitmjy','559794bmddZq','class\x20','throw','9wdFqeZ','catch','\x20\x20Map<String,\x20dynamic>\x20toJson()\x20=>\x20{\x0a','\x20\x20});','static','\x20is\x20bool\x20?\x20','isObject','5942538Fexmem','log','operator','async','num','3795696gaWpsM','null',')?.toList()\x20:\x20null','298351QFEtLW','show','\x20\x20\x20\x20\x20\x20\x20\x20','.fromJson(','return','interface','isBoolean','finally','extends','covariant','entries','?.toString()','5464670SZWmBo','.fromJson(Map<String,\x20dynamic>\x20json)\x20{\x0a','String','int','\x20=\x20','List','\x20\x20\x20\x20\x20\x20};','({\x0a','deferred','assert','?.toString()\x20??\x20\x27\x27)','yield','this','abstract','final','\x20\x20\x20\x20','\x20类包含值为\x22空\x22的属性,将被默认视为”String“类型','mixin','void','Function','includes','\x20\x20\x20\x20this.','enum','super','await','test','with','\x20:\x20null','implements','isInt','export','join',')\x20:\x20null','else','3522248xhNneZ','num.tryParse(','__esModule','bool','isNumber','snakeToCamel','\x20!=\x20null\x20&&\x20'];a0_0x4cee=function(){return _0x538fa8;};return a0_0x4cee();}function modelTypeGenerator(_0x4ffa5b,_0x3007eb,_0x106883,_0x2a472f){const _0x14765c=a0_0x52467b;if((0x0,js_utils_plus_1[_0x14765c(0x167)])(_0x4ffa5b))return{'type':_0x14765c(0x129),'typeTo':_0x220f1c=>_0x220f1c,'typeFrom':_0x2b3335=>_0x2b3335+_0x14765c(0x157)+_0x2b3335+_0x14765c(0x11f)};if((0x0,js_utils_plus_1['isString'])(_0x4ffa5b))return{'type':_0x14765c(0x106),'typeTo':_0x1ddb22=>_0x1ddb22,'typeFrom':_0x776488=>_0x776488+'?.toString()'};if((0x0,js_utils_plus_1[_0x14765c(0x12a)])(_0x4ffa5b)){if(_0x2a472f)return{'type':_0x14765c(0x15d),'typeTo':_0x267f54=>_0x267f54,'typeFrom':_0x468fa9=>_0x14765c(0x127)+_0x468fa9+'?.toString()\x20??\x20\x27\x27)'};return(0x0,js_utils_plus_1[_0x14765c(0x121)])(_0x4ffa5b)?{'type':_0x14765c(0x107),'typeTo':_0x39c34b=>_0x39c34b,'typeFrom':_0x278f0c=>_0x14765c(0x12e)+_0x278f0c+_0x14765c(0x10e)}:{'type':'double','typeTo':_0x434a3b=>_0x434a3b,'typeFrom':_0x3d465a=>'double.tryParse('+_0x3d465a+_0x14765c(0x10e)};}if((0x0,js_utils_plus_1[_0x14765c(0x158)])(_0x4ffa5b))return{'type':_0x3007eb,'typeTo':_0x181a34=>_0x181a34+_0x14765c(0x139),'typeFrom':_0x3e1254=>'('+_0x3e1254+'\x20!=\x20null\x20&&\x20'+_0x3e1254+'\x20is\x20Map<String,\x20dynamic>)\x20?\x20'+_0x3007eb+_0x14765c(0x164)+_0x3e1254+_0x14765c(0x124),'subLines':jsonToDart(_0x4ffa5b,_0x3007eb,_0x106883,_0x2a472f)};if((0x0,js_utils_plus_1[_0x14765c(0x14b)])(_0x4ffa5b)){const _0x5400f2=_0x4ffa5b[0x0];if(!_0x5400f2)console[_0x14765c(0x15a)](_0x14765c(0x134)+_0x3007eb+_0x14765c(0x114));const {type:_0x1c7982,typeTo:_0x3ea9ab,typeFrom:_0xcaebb6,subLines:_0x5db3e3}=modelTypeGenerator(_0x5400f2||'',_0x3007eb,_0x106883,_0x2a472f);return{'type':'List<'+_0x1c7982+(_0x106883?'?':'')+'>','typeTo':_0x48a8b2=>_0x48a8b2+_0x14765c(0x13d)+_0x3ea9ab('e')+_0x14765c(0x12f),'typeFrom':_0x56ae09=>'('+_0x56ae09+_0x14765c(0x12c)+_0x56ae09+_0x14765c(0x131)+_0x56ae09+'.map((e)\x20=>\x20'+_0xcaebb6('e')+_0x14765c(0x160),'subLines':_0x5db3e3};}return console[_0x14765c(0x15a)](_0x14765c(0x134)+_0x3007eb+_0x14765c(0x114)),{'type':'String','typeTo':_0x58ec2b=>_0x58ec2b,'typeFrom':_0x5693d9=>_0x5693d9+_0x14765c(0x103)};}function modelKeywordDefence(_0x44514d){const _0x4b092d=a0_0x52467b;let _0x533ba1=[_0x4b092d(0x15d),_0x4b092d(0x14a),_0x4b092d(0x107),_0x4b092d(0x106),'bool',_0x4b092d(0x109),_0x4b092d(0x111),_0x4b092d(0x14c),_0x4b092d(0x120),_0x4b092d(0x162),'as',_0x4b092d(0x125),_0x4b092d(0x136),_0x4b092d(0x156),_0x4b092d(0x10d),_0x4b092d(0x11a),'in',_0x4b092d(0x11b),_0x4b092d(0x15c),_0x4b092d(0x122),_0x4b092d(0x166),_0x4b092d(0x144),_0x4b092d(0x11c),_0x4b092d(0x100),'is',_0x4b092d(0x137),_0x4b092d(0x141),'external',_0x4b092d(0x130),_0x4b092d(0x110),_0x4b092d(0x14d),'factory',_0x4b092d(0x115),_0x4b092d(0x151),_0x4b092d(0x153),_0x4b092d(0x138),_0x4b092d(0x145),'true',_0x4b092d(0x143),_0x4b092d(0x112),_0x4b092d(0x15f),_0x4b092d(0x13a),'const',_0x4b092d(0x168),'on',_0x4b092d(0x13e),_0x4b092d(0x13f),'for',_0x4b092d(0x15b),'var',_0x4b092d(0x101),_0x4b092d(0x117),'part',_0x4b092d(0x116),_0x4b092d(0x149),_0x4b092d(0x132),_0x4b092d(0x140),_0x4b092d(0x142),_0x4b092d(0x10c),'hide',_0x4b092d(0x165),_0x4b092d(0x11e),'do','if',_0x4b092d(0x13c),_0x4b092d(0x10f)];if(_0x533ba1[_0x4b092d(0x118)](_0x44514d)||/^\d/[_0x4b092d(0x11d)](_0x44514d))return'the'+(0x0,js_utils_plus_1['uppercaseFirst'])(_0x44514d);return(0x0,js_utils_plus_1[_0x4b092d(0x12b)])(_0x44514d);}function jsonToDart(_0x2798bf,_0x132436,_0x426752,_0x299b75){const _0x5aa1c0=a0_0x52467b;_0x132436=(0x0,js_utils_plus_1['uppercaseFirst'])((0x0,js_utils_plus_1[_0x5aa1c0(0x12b)])(_0x132436));let _0x509d46=[],_0x27d758=[],_0xa86f2d=[],_0x37e486=[],_0xd135e1=[],_0x98791d=[];_0x509d46[_0x5aa1c0(0x12d)](_0x5aa1c0(0x150)+_0x132436+'\x20{'),_0xa86f2d[_0x5aa1c0(0x12d)]('\x20\x20'+_0x132436+_0x5aa1c0(0x10b)),_0x37e486[_0x5aa1c0(0x12d)]('\x20\x20'+_0x132436+_0x5aa1c0(0x105)),_0xd135e1['push'](_0x5aa1c0(0x154));for(const [_0x469320,_0x53b455]of Object[_0x5aa1c0(0x102)](_0x2798bf)){let _0x128a45='\x27'+_0x469320+'\x27',_0x337ef8=modelKeywordDefence(_0x469320);const _0x36508b=''+_0x132436+(0x0,js_utils_plus_1[_0x5aa1c0(0x135)])((0x0,js_utils_plus_1[_0x5aa1c0(0x12b)])(_0x469320)),{type:_0x176f6a,typeTo:_0x5d1cc7,typeFrom:_0x204a13,subLines:_0x50be02}=modelTypeGenerator(_0x53b455,_0x36508b,_0x426752,_0x299b75);if(_0x50be02)_0x98791d[_0x5aa1c0(0x12d)](_0x50be02);_0xa86f2d['push'](_0x5aa1c0(0x119)+_0x337ef8+',\x0a'),_0x27d758['push']('\x20\x20'+_0x176f6a+(_0x426752?'?':'')+'\x20'+_0x337ef8+';\x0a'),_0x37e486['push'](_0x5aa1c0(0x113)+_0x337ef8+_0x5aa1c0(0x108)+_0x204a13(_0x5aa1c0(0x133)+_0x128a45+']')+';\x0a'),_0xd135e1[_0x5aa1c0(0x12d)](_0x5aa1c0(0x163)+_0x128a45+':\x20'+_0x5d1cc7(_0x337ef8)+',\x0a');}return _0xa86f2d[_0x5aa1c0(0x12d)](_0x5aa1c0(0x155)),_0x37e486[_0x5aa1c0(0x12d)](_0x5aa1c0(0x146)),_0xd135e1['push'](_0x5aa1c0(0x10a)),_0x509d46[_0x5aa1c0(0x12d)](_0x27d758[_0x5aa1c0(0x123)]('')),_0x509d46['push'](_0xa86f2d[_0x5aa1c0(0x123)]('')),_0x509d46[_0x5aa1c0(0x12d)](_0x37e486[_0x5aa1c0(0x123)]('')),_0x509d46[_0x5aa1c0(0x12d)](_0xd135e1[_0x5aa1c0(0x123)]('')),_0x509d46['push']('}\x0a'),_0x509d46[_0x5aa1c0(0x12d)](_0x98791d[_0x5aa1c0(0x123)]('')),_0x509d46[_0x5aa1c0(0x123)]('\x0d\x0a');}
package/main/index.js CHANGED
@@ -1 +1 @@
1
- 'use strict';const a1_0x45525b=a1_0x1e94;function a1_0x1e94(_0x2732ac,_0x85edc8){const _0x14c271=a1_0x14c2();return a1_0x1e94=function(_0x1e9416,_0x2ccc49){_0x1e9416=_0x1e9416-0xd1;let _0x170b0a=_0x14c271[_0x1e9416];return _0x170b0a;},a1_0x1e94(_0x2732ac,_0x85edc8);}(function(_0x2ff6c7,_0x569ad3){const _0x90765a=a1_0x1e94,_0x7bda4=_0x2ff6c7();while(!![]){try{const _0x1b9e42=-parseInt(_0x90765a(0xe4))/0x1*(parseInt(_0x90765a(0xf7))/0x2)+parseInt(_0x90765a(0xfa))/0x3*(parseInt(_0x90765a(0xeb))/0x4)+parseInt(_0x90765a(0xf4))/0x5*(-parseInt(_0x90765a(0xd2))/0x6)+-parseInt(_0x90765a(0xe6))/0x7+-parseInt(_0x90765a(0xe7))/0x8*(parseInt(_0x90765a(0xe0))/0x9)+-parseInt(_0x90765a(0xd9))/0xa+parseInt(_0x90765a(0xf2))/0xb;if(_0x1b9e42===_0x569ad3)break;else _0x7bda4['push'](_0x7bda4['shift']());}catch(_0x3f0943){_0x7bda4['push'](_0x7bda4['shift']());}}}(a1_0x14c2,0xe1a94));function a1_0x14c2(){const _0x456b4a=['option','jsonToDart','json文件夹路径','5652130QQXCZc','writeFile','default','js-utils-plus','--nullsafety','cwd','__importDefault','172647RHSLRK','-\x20执行文件:','__esModule','name','2393gcFBYs','-d,\x20--dir\x20<dir>','8249857HKOwwX','40bTuVmZ','log','defineProperty','readFile','69108XVGstM','readDirFiles','parse','启用空安全','forEach','join','opts','61695271poDvfi','/lib/models/','7375055pBhChn','输出序列化模型路径,\x20默认lib/models','dir','1318ztbKHJ','requiredOption','json','36uKgQNz','需要排除的文件,可指定多个','6HrtIwG','excludes','-o,\x20--output\x20<dir>','.dart'];a1_0x14c2=function(){return _0x456b4a;};return a1_0x14c2();}var __importDefault=this&&this[a1_0x45525b(0xdf)]||function(_0x18d274){const _0x1bb767=a1_0x45525b;return _0x18d274&&_0x18d274[_0x1bb767(0xe2)]?_0x18d274:{'default':_0x18d274};};Object[a1_0x45525b(0xe9)](exports,a1_0x45525b(0xe2),{'value':!![]});const json2dart_1=require('./core/json2dart'),js_utils_plus_1=require(a1_0x45525b(0xdc)),commander_1=require('commander'),path_1=__importDefault(require('path')),program=new commander_1['Command'](),_path=process[a1_0x45525b(0xde)]();program[a1_0x45525b(0xf8)](a1_0x45525b(0xe5),a1_0x45525b(0xd8))[a1_0x45525b(0xd6)](a1_0x45525b(0xd4),a1_0x45525b(0xf5))[a1_0x45525b(0xd6)]('-e,\x20--excludes\x20<value...>',a1_0x45525b(0xd1))[a1_0x45525b(0xd6)](a1_0x45525b(0xdd),a1_0x45525b(0xee)),program[a1_0x45525b(0xed)]();const options=program[a1_0x45525b(0xf1)]();function run(){const _0x101ba8=a1_0x45525b,_0x2b02c0=path_1['default'][_0x101ba8(0xf0)](_path,options[_0x101ba8(0xf6)]),_0x1e9bbd=(0x0,js_utils_plus_1[_0x101ba8(0xec)])(_0x2b02c0,_0x101ba8(0xf9),options[_0x101ba8(0xd3)]||[]);console[_0x101ba8(0xe8)](new Array(0x50)[_0x101ba8(0xf0)]('-')),_0x1e9bbd[_0x101ba8(0xef)](function(_0x5bcf3){const _0xe8e732=_0x101ba8,_0x4f763d=(0x0,js_utils_plus_1[_0xe8e732(0xea)])(_0x5bcf3);if(!_0x4f763d||!(0x0,js_utils_plus_1['isJsonString'])(_0x4f763d)){console['error'](_0xe8e732(0xe1)+_0x5bcf3);return;}console[_0xe8e732(0xe8)](_0xe8e732(0xe1)+_0x5bcf3);const _0x435b7f=JSON[_0xe8e732(0xed)](_0x4f763d),_0xc7248e=path_1[_0xe8e732(0xdb)][_0xe8e732(0xed)](_0x5bcf3),_0x52d160=(0x0,json2dart_1[_0xe8e732(0xd7)])(_0x435b7f,_0xc7248e[_0xe8e732(0xe3)],options['nullsafety']),_0x1422aa=path_1[_0xe8e732(0xdb)][_0xe8e732(0xf0)](_path,options['output']||_0xe8e732(0xf3),_0xc7248e[_0xe8e732(0xe3)]+_0xe8e732(0xd5));(0x0,js_utils_plus_1[_0xe8e732(0xda)])(_0x1422aa,_0x52d160);});}run();
1
+ 'use strict';const a1_0x1bfc60=a1_0x51e5;function a1_0x363c(){const _0x1439c5=['2286641irinIm','__importDefault','requiredOption','output','.dart','js-utils-plus','--nullsafety','是否使用num处理数字类型,默认使用int和double','-d,\x20--dir\x20<dir>','readFile','json','json文件夹路径,默认\x20json_models','5yugpnY','name','590ZAttIz','option','Command','./core/json2dart','defineProperty','excludes','7546CubzfB','__esModule','483930RDhsWv','numparse','/lib/models/','cwd','join','--numparse','-\x20执行文件:','762004ndRDAm','path','98848uSWrJo','6Gzneja','commander','1awmgtU','suffix','nullsafety','-e,\x20--excludes\x20<value...>','isJsonString','746124wWRkTj','jsonToDart','734794aSQZJc','自定义dart模型类名后缀,如\x20Entity','parse','dart模型输出路径,默认\x20lib/models','readDirFiles','log','default','是否启用空安全','writeFile','144oQQHXI'];a1_0x363c=function(){return _0x1439c5;};return a1_0x363c();}(function(_0x230b0d,_0x12599a){const _0x48bcdb=a1_0x51e5,_0x52b937=_0x230b0d();while(!![]){try{const _0x1edf1a=-parseInt(_0x48bcdb(0x13f))/0x1*(parseInt(_0x48bcdb(0x146))/0x2)+-parseInt(_0x48bcdb(0x166))/0x3+parseInt(_0x48bcdb(0x16d))/0x4*(parseInt(_0x48bcdb(0x15c))/0x5)+-parseInt(_0x48bcdb(0x13d))/0x6*(-parseInt(_0x48bcdb(0x150))/0x7)+parseInt(_0x48bcdb(0x16f))/0x8*(parseInt(_0x48bcdb(0x14f))/0x9)+parseInt(_0x48bcdb(0x15e))/0xa*(-parseInt(_0x48bcdb(0x164))/0xb)+parseInt(_0x48bcdb(0x144))/0xc;if(_0x1edf1a===_0x12599a)break;else _0x52b937['push'](_0x52b937['shift']());}catch(_0xca3255){_0x52b937['push'](_0x52b937['shift']());}}}(a1_0x363c,0x32bf0));function a1_0x51e5(_0x135ce5,_0x36b347){const _0x363c6b=a1_0x363c();return a1_0x51e5=function(_0x51e56e,_0x48fa75){_0x51e56e=_0x51e56e-0x13d;let _0x9ca228=_0x363c6b[_0x51e56e];return _0x9ca228;},a1_0x51e5(_0x135ce5,_0x36b347);}var __importDefault=this&&this[a1_0x1bfc60(0x151)]||function(_0x98b9f7){const _0x3c9ee2=a1_0x1bfc60;return _0x98b9f7&&_0x98b9f7[_0x3c9ee2(0x165)]?_0x98b9f7:{'default':_0x98b9f7};};Object[a1_0x1bfc60(0x162)](exports,a1_0x1bfc60(0x165),{'value':!![]});const json2dart_1=require(a1_0x1bfc60(0x161)),js_utils_plus_1=require(a1_0x1bfc60(0x155)),commander_1=require(a1_0x1bfc60(0x13e)),path_1=__importDefault(require(a1_0x1bfc60(0x16e))),program=new commander_1[(a1_0x1bfc60(0x160))](),_path=process[a1_0x1bfc60(0x169)]();program[a1_0x1bfc60(0x152)](a1_0x1bfc60(0x158),a1_0x1bfc60(0x15b))['option']('-o,\x20--output\x20<dir>',a1_0x1bfc60(0x149))[a1_0x1bfc60(0x15f)]('-s,\x20--suffix\x20<value>',a1_0x1bfc60(0x147))[a1_0x1bfc60(0x15f)](a1_0x1bfc60(0x142),'需要排除的json文件,可指定多个文件')['option'](a1_0x1bfc60(0x16b),a1_0x1bfc60(0x157))['option'](a1_0x1bfc60(0x156),a1_0x1bfc60(0x14d)),program['parse']();const options=program['opts']();function run(){const _0x44f14c=a1_0x1bfc60,_0x345b8f=path_1[_0x44f14c(0x14c)]['join'](_path,options['dir']),_0x4b545e=(0x0,js_utils_plus_1[_0x44f14c(0x14a)])(_0x345b8f,_0x44f14c(0x15a),options[_0x44f14c(0x163)]||[]);console[_0x44f14c(0x14b)](new Array(0x50)['join']('-')),_0x4b545e['forEach'](function(_0x145899){const _0xc31d52=_0x44f14c,_0x9c3190=(0x0,js_utils_plus_1[_0xc31d52(0x159)])(_0x145899);if(!_0x9c3190||!(0x0,js_utils_plus_1[_0xc31d52(0x143)])(_0x9c3190)){console['error'](_0xc31d52(0x16c)+_0x145899);return;}console[_0xc31d52(0x14b)]('-\x20执行文件:'+_0x145899);const _0x2a9c49=JSON[_0xc31d52(0x148)](_0x9c3190),_0x3c20b7=path_1['default'][_0xc31d52(0x148)](_0x145899),_0x8e87b=(0x0,json2dart_1[_0xc31d52(0x145)])(_0x2a9c49,options[_0xc31d52(0x140)]?''+_0x3c20b7[_0xc31d52(0x15d)]+options['suffix']:_0x3c20b7[_0xc31d52(0x15d)],options[_0xc31d52(0x141)],options[_0xc31d52(0x167)]),_0x2c4db4=path_1[_0xc31d52(0x14c)][_0xc31d52(0x16a)](_path,options[_0xc31d52(0x153)]||_0xc31d52(0x168),_0x3c20b7[_0xc31d52(0x15d)]+_0xc31d52(0x154));(0x0,js_utils_plus_1[_0xc31d52(0x14e)])(_0x2c4db4,_0x8e87b);});}run();
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "json2dart-generator",
3
- "version": "0.0.1",
3
+ "version": "0.0.6",
4
4
  "description": "json to dart model generator",
5
5
  "main": "main/index.js",
6
6
  "bin": {
7
7
  "json2dart": "main/index.js"
8
8
  },
9
9
  "scripts": {
10
- "test": "tsc --module commonjs && node dist/index.js -d ./.json_models --nullsafety",
10
+ "test": "tsc --module commonjs && node dist/index.js -d ./json_models -o ./models -s Entity --nullsafety --numparse",
11
11
  "dev": "tsc -w",
12
12
  "build": "rimraf dist && rimraf main && tsc && javascript-obfuscator dist --output main"
13
13
  },