json2dart-generator 0.0.2 → 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
 
@@ -17,11 +17,18 @@ json2dart options
17
17
 
18
18
  Options:
19
19
  -d, --dir <dir> json文件夹路径,默认 json_models
20
- -o, --output <file> 输出序列化模型路径,默认 lib/models
21
- -e, --excludes <value...> 需要排除的文件,可指定多个文件
22
- --nullsafety 启用空安全
20
+ -o, --output <dir> dart模型输出路径,默认 lib/models
21
+ -s, --suffix <value> 自定义dart模型类名后缀,如 Entity
22
+ -e, --excludes <value...> 需要排除的json文件,可指定多个文件
23
+ --numparse 是否使用num处理数字类型
24
+ --nullsafety 是否启用空安全
23
25
  ```
24
26
 
27
+ - 备注:
28
+ - 根类名为`json`的文件名(首字母自动转为大写,并且蛇形自动转驼峰)。
29
+ - 类的属性名自动蛇形转驼峰,当属性名为`dart关键字`时将在名称前面加`the`。
30
+ - 当`json`的值类型不存在或空时,自动默认处理为`String`类型并控制台输出警告。
31
+
25
32
  - 帮助文档
26
33
 
27
34
  ```bash
@@ -34,12 +41,9 @@ json2dart --help
34
41
  json2dart --dir ./json_models -o lib/models --nullsafety
35
42
  ```
36
43
 
37
- - 备注:
38
- - 根类名为`json`的文件名(首字母自动转为大写)。
39
-
40
44
  ### 示例
41
45
 
42
- - commonLang.json
46
+ - test.json
43
47
 
44
48
  ```json
45
49
  {
@@ -61,18 +65,18 @@ json2dart --dir ./json_models -o lib/models --nullsafety
61
65
  }
62
66
  ```
63
67
 
64
- - commonLang.dart
68
+ - test.dart
65
69
 
66
70
  ```dart
67
- class CommonLang {
71
+ class Test {
68
72
  String? id;
69
73
  String? parentId;
70
74
  String? name;
71
75
  String? value;
72
76
  List<String?>? codes;
73
- CommonLangData? data;
77
+ TestData? data;
74
78
 
75
- CommonLang({
79
+ Test({
76
80
  this.id,
77
81
  this.parentId,
78
82
  this.name,
@@ -80,25 +84,25 @@ class CommonLang {
80
84
  this.codes,
81
85
  this.data,
82
86
  });
83
- CommonLang.fromJson(Map<String, dynamic> json) {
87
+ Test.fromJson(Map<String, dynamic> json) {
84
88
  id = json['id']?.toString();
85
89
  parentId = json['parentId']?.toString();
86
90
  name = json['name']?.toString();
87
91
  value = json['value']?.toString();
88
- codes = List<String>.from(json['codes'] ?? []);
89
- 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;
90
94
  }
91
95
  Map<String, dynamic> toJson() => {
92
96
  'id': id,
93
97
  'parentId': parentId,
94
98
  'name': name,
95
99
  'value': value,
96
- 'codes': codes,
100
+ 'codes': codes?.map((e) => e)?.toList(),
97
101
  'data': data?.toJson(),
98
102
  };
99
103
  }
100
104
 
101
- class CommonLangData {
105
+ class TestData {
102
106
  String? dicCode;
103
107
  String? defaultValue;
104
108
  String? groupId;
@@ -108,7 +112,7 @@ class CommonLangData {
108
112
  int? showOrder;
109
113
  String? dicName;
110
114
 
111
- CommonLangData({
115
+ TestData({
112
116
  this.dicCode,
113
117
  this.defaultValue,
114
118
  this.groupId,
@@ -118,7 +122,7 @@ class CommonLangData {
118
122
  this.showOrder,
119
123
  this.dicName,
120
124
  });
121
- CommonLangData.fromJson(Map<String, dynamic> json) {
125
+ TestData.fromJson(Map<String, dynamic> json) {
122
126
  dicCode = json['dicCode']?.toString();
123
127
  defaultValue = json['defaultValue']?.toString();
124
128
  groupId = json['groupId']?.toString();
@@ -1 +1 @@
1
- 'use strict';function a0_0xe4cb(){const _0xbe97ed=['isNumber','isString','1368sYWbWl','assert','isArray','push','bool','extends','.fromJson(Map<String,\x20dynamic>\x20json)\x20{\x0a','.fromJson(','includes','num','operator','test','double.tryParse(','\x20!=\x20null\x20?\x20','part','json[','?.toString()\x20??\x20\x27\x27)','9664ucyviH','670368bNThta','return','169206gnUcEd','var','async','?.toString()','the','await','469hvtHAm','\x20\x20\x20\x20this.','rethrow','>.from(','\x20as\x20List<dynamic>)?.map((e)\x20=>\x20','finally','\x20\x20}','class\x20','\x20\x20Map<String,\x20dynamic>\x20toJson()\x20=>\x20{\x0a','set','isBoolean','show','44JJtsfT','implements','({\x0a','get','while','interface','yield','?.map((e)\x20=>\x20','export','final','String','\x20\x20});','double','log','WARNING\x20:\x20','222840HPiFhD','int','static','deferred','mixin','5vLSAzf','\x20\x20\x20\x20','entries','class','external','__esModule','6cesMsF','\x20has\x20Property\x20is\x20null,which\x20will\x20be\x20treated\x20as\x20String\x20type','14330pMFnfQ','import','break','super','join',')\x20:\x20null','List<','abstract','sync','const','uppercaseFirst','Function','covariant','520092KGGXWC','case','else','\x20\x20\x20\x20\x20\x20};','catch','factory','List','snakeToCamel','void','172641bCkKVf','isInt','isObject','jsonToDart'];a0_0xe4cb=function(){return _0xbe97ed;};return a0_0xe4cb();}const a0_0x130589=a0_0xf6d0;(function(_0x58f418,_0x108b81){const _0x39ce3d=a0_0xf6d0,_0x531330=_0x58f418();while(!![]){try{const _0x59b940=parseInt(_0x39ce3d(0xc4))/0x1+parseInt(_0x39ce3d(0xac))/0x2*(-parseInt(_0x39ce3d(0xa1))/0x3)+-parseInt(_0x39ce3d(0x7e))/0x4+-parseInt(_0x39ce3d(0xa6))/0x5*(-parseInt(_0x39ce3d(0x80))/0x6)+parseInt(_0x39ce3d(0x86))/0x7*(-parseInt(_0x39ce3d(0x7d))/0x8)+parseInt(_0x39ce3d(0x6c))/0x9*(parseInt(_0x39ce3d(0xae))/0xa)+-parseInt(_0x39ce3d(0x92))/0xb*(-parseInt(_0x39ce3d(0xbb))/0xc);if(_0x59b940===_0x108b81)break;else _0x531330['push'](_0x531330['shift']());}catch(_0x2f73be){_0x531330['push'](_0x531330['shift']());}}}(a0_0xe4cb,0x1d74e));Object['defineProperty'](exports,a0_0x130589(0xab),{'value':!![]}),exports[a0_0x130589(0x69)]=jsonToDart;function a0_0xf6d0(_0x124080,_0x488c14){const _0xe4cb6d=a0_0xe4cb();return a0_0xf6d0=function(_0xf6d084,_0x4441e3){_0xf6d084=_0xf6d084-0x67;let _0x1ba953=_0xe4cb6d[_0xf6d084];return _0x1ba953;},a0_0xf6d0(_0x124080,_0x488c14);}const js_utils_plus_1=require('js-utils-plus');function modelTypeGenerator(_0x1846ee,_0x4fae06,_0x431f7a){const _0x1c6c3b=a0_0x130589;if((0x0,js_utils_plus_1[_0x1c6c3b(0x90)])(_0x1846ee))return{'type':_0x1c6c3b(0x70),'typeTo':_0x3b5145=>_0x3b5145,'typeFrom':_0x43fd96=>''+_0x43fd96};if((0x0,js_utils_plus_1[_0x1c6c3b(0x6b)])(_0x1846ee))return{'type':'String','typeTo':_0x1d9fd3=>_0x1d9fd3,'typeFrom':_0x6d4c26=>_0x6d4c26+'?.toString()'};if((0x0,js_utils_plus_1[_0x1c6c3b(0x6a)])(_0x1846ee))return(0x0,js_utils_plus_1[_0x1c6c3b(0x67)])(_0x1846ee)?{'type':_0x1c6c3b(0xa2),'typeTo':_0x58f3e5=>_0x58f3e5,'typeFrom':_0x4f6e68=>'int.tryParse('+_0x4f6e68+_0x1c6c3b(0x7c)}:{'type':'double','typeTo':_0x2c3efb=>_0x2c3efb,'typeFrom':_0xc16f3c=>_0x1c6c3b(0x78)+_0xc16f3c+_0x1c6c3b(0x7c)};if((0x0,js_utils_plus_1[_0x1c6c3b(0x68)])(_0x1846ee))return{'type':_0x4fae06,'typeTo':_0x85503b=>_0x85503b+'?.toJson()','typeFrom':_0xe3ac11=>_0xe3ac11+_0x1c6c3b(0x79)+_0x4fae06+_0x1c6c3b(0x73)+_0xe3ac11+_0x1c6c3b(0xb3),'subLines':jsonToDart(_0x1846ee,_0x4fae06,_0x431f7a)};if((0x0,js_utils_plus_1[_0x1c6c3b(0x6e)])(_0x1846ee)){const _0x186778=_0x1846ee[0x0];if(!_0x186778)console[_0x1c6c3b(0x9f)](_0x1c6c3b(0xa0)+_0x4fae06+'\x20has\x20Property\x20is\x20null,which\x20will\x20be\x20treated\x20as\x20String\x20type');const {type:_0x149469,typeTo:_0x363521,typeFrom:_0x411aaf,subLines:_0x453370}=modelTypeGenerator(_0x186778||'',_0x4fae06,_0x431f7a);if([_0x1c6c3b(0x70),_0x1c6c3b(0x9c),_0x1c6c3b(0xa2),_0x1c6c3b(0x9e)][_0x1c6c3b(0x74)](_0x149469))return{'type':_0x1c6c3b(0xb4)+_0x149469+(_0x431f7a?'?':'')+'>','typeTo':_0x3e3bcb=>_0x3e3bcb,'typeFrom':_0x25a933=>_0x1c6c3b(0xb4)+_0x149469+_0x1c6c3b(0x89)+_0x25a933+'\x20??\x20[])'};return{'type':_0x1c6c3b(0xb4)+_0x149469+(_0x431f7a?'?':'')+'>','typeTo':_0x594f21=>_0x594f21+_0x1c6c3b(0x99)+_0x363521('e')+')?.toList()','typeFrom':_0x4a0216=>'('+_0x4a0216+_0x1c6c3b(0x8a)+_0x411aaf('e')+'\x20)?.toList()','subLines':_0x453370};}return console[_0x1c6c3b(0x9f)](_0x1c6c3b(0xa0)+_0x4fae06+_0x1c6c3b(0xad)),{'type':'String','typeTo':_0x2385f6=>_0x2385f6,'typeFrom':_0x3719c7=>_0x3719c7+_0x1c6c3b(0x83)};}function modelKeywordDefence(_0x1d24d0){const _0x1b9e16=a0_0x130589;let _0x25fe6b=[_0x1b9e16(0x75),_0x1b9e16(0x9e),_0x1b9e16(0xa2),_0x1b9e16(0x9c),_0x1b9e16(0x70),_0x1b9e16(0xc1),_0x1b9e16(0xb5),'dynamic',_0x1b9e16(0x93),_0x1b9e16(0x91),'as',_0x1b9e16(0xbd),_0x1b9e16(0xaf),_0x1b9e16(0xa3),_0x1b9e16(0x6d),'enum','in',_0x1b9e16(0xb1),_0x1b9e16(0x82),_0x1b9e16(0x9a),_0x1b9e16(0x97),'switch',_0x1b9e16(0x85),_0x1b9e16(0x71),'is',_0x1b9e16(0xb6),_0x1b9e16(0xb0),_0x1b9e16(0xaa),'library','this',_0x1b9e16(0xbc),_0x1b9e16(0xc0),_0x1b9e16(0xa5),'throw',_0x1b9e16(0xbf),'false','new','true',_0x1b9e16(0xa9),_0x1b9e16(0x9b),'null','try',_0x1b9e16(0xb7),_0x1b9e16(0x8b),'on','typedef','continue','for',_0x1b9e16(0x76),_0x1b9e16(0x81),_0x1b9e16(0xba),_0x1b9e16(0xb9),_0x1b9e16(0x7a),_0x1b9e16(0xc3),'default',_0x1b9e16(0x95),_0x1b9e16(0x88),_0x1b9e16(0x96),_0x1b9e16(0xa4),'hide',_0x1b9e16(0x7f),'with','do','if',_0x1b9e16(0x8f),_0x1b9e16(0x98)];if(_0x25fe6b[_0x1b9e16(0x74)](_0x1d24d0)||/^\d/[_0x1b9e16(0x77)](_0x1d24d0))return _0x1b9e16(0x84)+(0x0,js_utils_plus_1['uppercaseFirst'])(_0x1d24d0);return(0x0,js_utils_plus_1[_0x1b9e16(0xc2)])(_0x1d24d0);}function jsonToDart(_0x40d55c,_0x3135d2,_0x169ecf){const _0x51c62c=a0_0x130589;_0x3135d2=(0x0,js_utils_plus_1[_0x51c62c(0xb8)])((0x0,js_utils_plus_1['snakeToCamel'])(_0x3135d2));let _0x3c896f=[],_0x53dd90=[],_0x4434d9=[],_0x2adc5a=[],_0x1feaee=[],_0x380f11=[];_0x3c896f[_0x51c62c(0x6f)](_0x51c62c(0x8d)+_0x3135d2+'\x20{'),_0x4434d9[_0x51c62c(0x6f)]('\x20\x20'+_0x3135d2+_0x51c62c(0x94)),_0x2adc5a[_0x51c62c(0x6f)]('\x20\x20'+_0x3135d2+_0x51c62c(0x72)),_0x1feaee['push'](_0x51c62c(0x8e));for(const [_0x42a249,_0x276f14]of Object[_0x51c62c(0xa8)](_0x40d55c)){let _0x5f2750='\x27'+_0x42a249+'\x27',_0x3c009d=modelKeywordDefence(_0x42a249);const _0x32a18f=''+_0x3135d2+(0x0,js_utils_plus_1[_0x51c62c(0xb8)])((0x0,js_utils_plus_1[_0x51c62c(0xc2)])(_0x42a249)),{type:_0x582b50,typeTo:_0x8d0409,typeFrom:_0x32c396,subLines:_0x72a150}=modelTypeGenerator(_0x276f14,_0x32a18f,_0x169ecf);if(_0x72a150)_0x380f11[_0x51c62c(0x6f)](_0x72a150);_0x4434d9[_0x51c62c(0x6f)](_0x51c62c(0x87)+_0x3c009d+',\x0a'),_0x53dd90['push']('\x20\x20'+_0x582b50+(_0x169ecf?'?':'')+'\x20'+_0x3c009d+';\x0a'),_0x2adc5a[_0x51c62c(0x6f)](_0x51c62c(0xa7)+_0x3c009d+'\x20=\x20'+_0x32c396(_0x51c62c(0x7b)+_0x5f2750+']')+';\x0a'),_0x1feaee[_0x51c62c(0x6f)]('\x20\x20\x20\x20\x20\x20\x20\x20'+_0x5f2750+':\x20'+_0x8d0409(_0x3c009d)+',\x0a');}return _0x4434d9[_0x51c62c(0x6f)](_0x51c62c(0x9d)),_0x2adc5a[_0x51c62c(0x6f)](_0x51c62c(0x8c)),_0x1feaee[_0x51c62c(0x6f)](_0x51c62c(0xbe)),_0x3c896f['push'](_0x53dd90[_0x51c62c(0xb2)]('')),_0x3c896f[_0x51c62c(0x6f)](_0x4434d9[_0x51c62c(0xb2)]('')),_0x3c896f[_0x51c62c(0x6f)](_0x2adc5a[_0x51c62c(0xb2)]('')),_0x3c896f[_0x51c62c(0x6f)](_0x1feaee[_0x51c62c(0xb2)]('')),_0x3c896f['push']('}\x0a'),_0x3c896f[_0x51c62c(0x6f)](_0x380f11[_0x51c62c(0xb2)]('')),_0x3c896f[_0x51c62c(0xb2)]('\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_0x2f0332=a1_0x5a42;(function(_0x3e262b,_0x5459c1){const _0x4a4ff7=a1_0x5a42,_0xe06a96=_0x3e262b();while(!![]){try{const _0x4693ae=-parseInt(_0x4a4ff7(0x146))/0x1+parseInt(_0x4a4ff7(0x147))/0x2*(parseInt(_0x4a4ff7(0x132))/0x3)+parseInt(_0x4a4ff7(0x14d))/0x4+-parseInt(_0x4a4ff7(0x148))/0x5*(-parseInt(_0x4a4ff7(0x154))/0x6)+parseInt(_0x4a4ff7(0x14a))/0x7*(parseInt(_0x4a4ff7(0x13a))/0x8)+parseInt(_0x4a4ff7(0x151))/0x9+-parseInt(_0x4a4ff7(0x138))/0xa;if(_0x4693ae===_0x5459c1)break;else _0xe06a96['push'](_0xe06a96['shift']());}catch(_0x100360){_0xe06a96['push'](_0xe06a96['shift']());}}}(a1_0x4d4e,0x710b4));function a1_0x5a42(_0x36f8e0,_0x5c9bfd){const _0x4d4e2c=a1_0x4d4e();return a1_0x5a42=function(_0x5a4214,_0x201f74){_0x5a4214=_0x5a4214-0x12d;let _0x1d9153=_0x4d4e2c[_0x5a4214];return _0x1d9153;},a1_0x5a42(_0x36f8e0,_0x5c9bfd);}function a1_0x4d4e(){const _0x415de8=['11323160Haxork','jsonToDart','45200jApStx','output','default','commander','json','-e,\x20--excludes\x20<value...>','writeFile','requiredOption','isJsonString','./core/json2dart','path','readDirFiles','438726RWaRpH','2lTuogY','1774170ctpdxL','join','651VDJuFZ','option','--nullsafety','1102384tLwRwj','.dart','nullsafety','输出序列化模型路径,\x20默认lib/models','2907504UQTJzU','-o,\x20--output\x20<dir>','name','6VTqShO','启用空安全','json文件夹路径','dir','js-utils-plus','error','parse','1665402jKDzQe','-\x20执行文件:','forEach','__esModule','-d,\x20--dir\x20<dir>','log'];a1_0x4d4e=function(){return _0x415de8;};return a1_0x4d4e();}var __importDefault=this&&this['__importDefault']||function(_0x2835c2){const _0x780284=a1_0x5a42;return _0x2835c2&&_0x2835c2[_0x780284(0x135)]?_0x2835c2:{'default':_0x2835c2};};Object['defineProperty'](exports,a1_0x2f0332(0x135),{'value':!![]});const json2dart_1=require(a1_0x2f0332(0x143)),js_utils_plus_1=require(a1_0x2f0332(0x12f)),commander_1=require(a1_0x2f0332(0x13d)),path_1=__importDefault(require(a1_0x2f0332(0x144))),program=new commander_1['Command'](),_path=process['cwd']();program[a1_0x2f0332(0x141)](a1_0x2f0332(0x136),a1_0x2f0332(0x12d))[a1_0x2f0332(0x14b)](a1_0x2f0332(0x152),a1_0x2f0332(0x150))[a1_0x2f0332(0x14b)](a1_0x2f0332(0x13f),'需要排除的文件,可指定多个')[a1_0x2f0332(0x14b)](a1_0x2f0332(0x14c),a1_0x2f0332(0x155)),program[a1_0x2f0332(0x131)]();const options=program['opts']();function run(){const _0x54a0f0=a1_0x2f0332,_0x17cac8=path_1[_0x54a0f0(0x13c)][_0x54a0f0(0x149)](_path,options[_0x54a0f0(0x12e)]),_0x1cd629=(0x0,js_utils_plus_1[_0x54a0f0(0x145)])(_0x17cac8,_0x54a0f0(0x13e),options['excludes']||[]);console[_0x54a0f0(0x137)](new Array(0x50)[_0x54a0f0(0x149)]('-')),_0x1cd629[_0x54a0f0(0x134)](function(_0x3e6aa6){const _0x406934=_0x54a0f0,_0xfbce60=(0x0,js_utils_plus_1['readFile'])(_0x3e6aa6);if(!_0xfbce60||!(0x0,js_utils_plus_1[_0x406934(0x142)])(_0xfbce60)){console[_0x406934(0x130)](_0x406934(0x133)+_0x3e6aa6);return;}console[_0x406934(0x137)]('-\x20执行文件:'+_0x3e6aa6);const _0x4312eb=JSON['parse'](_0xfbce60),_0x5b3753=path_1[_0x406934(0x13c)][_0x406934(0x131)](_0x3e6aa6),_0x17305b=(0x0,json2dart_1[_0x406934(0x139)])(_0x4312eb,_0x5b3753['name'],options[_0x406934(0x14f)]),_0x2e8d7f=path_1[_0x406934(0x13c)][_0x406934(0x149)](_path,options[_0x406934(0x13b)]||'/lib/models/',_0x5b3753[_0x406934(0x153)]+_0x406934(0x14e));(0x0,js_utils_plus_1[_0x406934(0x140)])(_0x2e8d7f,_0x17305b);});}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.2",
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
  },