json2dart-generator 0.0.1 → 0.0.2
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 +22 -5
- package/main/core/json2dart.js +1 -1
- package/main/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,16 +16,32 @@ npm install json2dart-generator -g
|
|
|
16
16
|
json2dart options
|
|
17
17
|
|
|
18
18
|
Options:
|
|
19
|
-
-d, --dir <dir> json
|
|
20
|
-
-
|
|
21
|
-
-
|
|
19
|
+
-d, --dir <dir> json文件夹路径,默认 json_models
|
|
20
|
+
-o, --output <file> 输出序列化模型路径,默认 lib/models
|
|
21
|
+
-e, --excludes <value...> 需要排除的文件,可指定多个文件
|
|
22
22
|
--nullsafety 启用空安全
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
- 帮助文档
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
json2dart --help
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- 执行命令
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
json2dart --dir ./json_models -o lib/models --nullsafety
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
- 备注:
|
|
38
|
+
- 根类名为`json`的文件名(首字母自动转为大写)。
|
|
39
|
+
|
|
25
40
|
### 示例
|
|
26
41
|
|
|
42
|
+
- commonLang.json
|
|
43
|
+
|
|
27
44
|
```json
|
|
28
|
-
// commonLang.json
|
|
29
45
|
{
|
|
30
46
|
"id": "467366309705273344",
|
|
31
47
|
"parentId": "0",
|
|
@@ -45,6 +61,8 @@ Options:
|
|
|
45
61
|
}
|
|
46
62
|
```
|
|
47
63
|
|
|
64
|
+
- commonLang.dart
|
|
65
|
+
|
|
48
66
|
```dart
|
|
49
67
|
class CommonLang {
|
|
50
68
|
String? id;
|
|
@@ -122,5 +140,4 @@ class CommonLangData {
|
|
|
122
140
|
};
|
|
123
141
|
}
|
|
124
142
|
|
|
125
|
-
|
|
126
143
|
```
|
package/main/core/json2dart.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';function
|
|
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');}
|
package/main/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';const
|
|
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();
|