json2dart-generator 1.0.1 → 1.1.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/dist/core/json2dart.d.ts +4 -1
- package/dist/core/json2dart.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/core/json2dart.d.ts
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export declare function jsonToDart(value: any, className: string, suffix: string, nullSafety: boolean, numparse: boolean):
|
|
1
|
+
export declare function jsonToDart(value: any, className: string, suffix: string, nullSafety: boolean, numparse: boolean, isRoot?: boolean): {
|
|
2
|
+
context: string;
|
|
3
|
+
className?: string;
|
|
4
|
+
};
|
package/dist/core/json2dart.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';
|
|
1
|
+
'use strict';const a0_0x57ee35=a0_0x5c59;(function(_0x13426f,_0x3d44f2){const _0xef4637=a0_0x5c59,_0x4ed610=_0x13426f();while(!![]){try{const _0x17c6fa=parseInt(_0xef4637(0x1e2))/0x1*(parseInt(_0xef4637(0x204))/0x2)+-parseInt(_0xef4637(0x20d))/0x3*(-parseInt(_0xef4637(0x1ca))/0x4)+-parseInt(_0xef4637(0x1da))/0x5+parseInt(_0xef4637(0x1ae))/0x6+parseInt(_0xef4637(0x205))/0x7*(-parseInt(_0xef4637(0x20a))/0x8)+parseInt(_0xef4637(0x1b2))/0x9+parseInt(_0xef4637(0x1cc))/0xa*(-parseInt(_0xef4637(0x206))/0xb);if(_0x17c6fa===_0x3d44f2)break;else _0x4ed610['push'](_0x4ed610['shift']());}catch(_0x520c78){_0x4ed610['push'](_0x4ed610['shift']());}}}(a0_0x2277,0xd2ba2));Object[a0_0x57ee35(0x1f8)](exports,a0_0x57ee35(0x209),{'value':!![]}),exports['jsonToDart']=jsonToDart;const js_utils_plus_1=require(a0_0x57ee35(0x1ea));function modelTypeGenerator(_0x2855a7,_0x3b1bc2,_0xdeb83f,_0x521d43,_0x492b0d,_0x1c4916){const _0x452ccc=a0_0x57ee35;if((0x0,js_utils_plus_1[_0x452ccc(0x1fb)])(_0x3b1bc2))return{'type':'bool','typeTo':_0x5ef785=>_0x5ef785,'typeFrom':_0x1b9f8a=>_0x1b9f8a+_0x452ccc(0x1e6)};if((0x0,js_utils_plus_1[_0x452ccc(0x1b6)])(_0x3b1bc2))return{'type':_0x452ccc(0x1d9),'typeTo':_0xb3f164=>_0xb3f164,'typeFrom':_0xfb15a9=>_0xfb15a9+'?.toString()'};if((0x0,js_utils_plus_1[_0x452ccc(0x1dd)])(_0x3b1bc2)){if(_0x1c4916)return{'type':_0x452ccc(0x1ce),'typeTo':_0x551e6d=>_0x551e6d,'typeFrom':_0x310ac1=>'num.tryParse('+_0x310ac1+_0x452ccc(0x1e7)};return(0x0,js_utils_plus_1[_0x452ccc(0x1af)])(_0x3b1bc2)?{'type':'int','typeTo':_0x2c11ef=>_0x2c11ef,'typeFrom':_0x5ad4e1=>_0x452ccc(0x1ff)+_0x5ad4e1+_0x452ccc(0x1e7)}:{'type':_0x452ccc(0x1f1),'typeTo':_0x523e24=>_0x523e24,'typeFrom':_0x50867a=>_0x452ccc(0x1bb)+_0x50867a+_0x452ccc(0x1e7)};}if((0x0,js_utils_plus_1['isObject'])(_0x3b1bc2)){const _0x56e584=jsonToDart(_0x3b1bc2,_0xdeb83f,_0x521d43,_0x492b0d,_0x1c4916,![]);return _0xdeb83f=_0x56e584['className']||_0xdeb83f,{'type':''+_0xdeb83f+_0x521d43,'typeTo':_0xac0b13=>_0xac0b13+_0x452ccc(0x201),'typeFrom':_0x19947d=>''+_0xdeb83f+_0x521d43+'.fromJson('+_0x19947d+'\x20as\x20Map<String,\x20dynamic>?)','subLines':_0x56e584[_0x452ccc(0x1d8)]};}if((0x0,js_utils_plus_1[_0x452ccc(0x1e0)])(_0x3b1bc2)){const _0x192f9e=_0x3b1bc2[0x0],{type:_0x3f1dd7,typeTo:_0x286898,typeFrom:_0x34c534,subLines:_0xc72df6}=modelTypeGenerator(_0x2855a7,_0x192f9e,_0xdeb83f,_0x521d43,_0x492b0d,_0x1c4916);return{'type':_0x452ccc(0x1c4)+_0x3f1dd7+(_0x492b0d?'?':'')+'>','typeTo':_0xcd4e62=>_0xcd4e62+_0x452ccc(0x1fc)+_0x286898('e')+_0x452ccc(0x1c6),'typeFrom':_0xf807eb=>'('+_0xf807eb+_0x452ccc(0x1c2)+_0x34c534('e')+_0x452ccc(0x1c6),'subLines':_0xc72df6};}return console[_0x452ccc(0x208)](_0x452ccc(0x20b)+_0x2855a7+_0x452ccc(0x1c7)),{'type':_0x452ccc(0x1d9),'typeTo':_0x3dced5=>_0x3dced5,'typeFrom':_0x123c3e=>_0x123c3e+_0x452ccc(0x1e4)};}function a0_0x2277(){const _0x482b34=['isNumber','deferred','\x20\x20}','isArray','yield','8153GsPAil','entries','?.toString()','else','\x20as\x20bool?','?.toString()\x20??\x20\x27\x27)','const','typedef','js-utils-plus','\x20\x20\x20\x20','factory','class\x20','case','join','class','double','List','sync','operator','continue','void','json?[','defineProperty','uppercaseFirst','default','isBoolean','?.map((e)\x20=>\x20','try','_classMap','int.tryParse(','var','?.toJson()','map','true','362CuNgJt','21574gpxAQt','341URomWw','show','log','__esModule','1112NldCPL','-\x20警告!:”','covariant','21iJsypu','snakeToCamel','81762nueOGC','isInt','push','async','2033244WzigHA','finally','\x20\x20Map<String,\x20dynamic>\x20toJson()\x20=>\x20{\x0a','null','isString','includes','this','Function','while','double.tryParse(','false','library','abstract','super','return','.fromJson(Map<String,\x20dynamic>?\x20json)\x20{\x0a','\x20as\x20List<dynamic>?)?.map((e)\x20=>\x20','the','List<','throw',').toList()','”\x20值包含为\x22空\x22的属性值或列表项,将被默认视为”String“类型','rethrow','external','600436GDlYWZ','\x20\x20});','134110LpqVTE','part','num','get','with','set','bool','for','extends','assert','interface','catch','context','String','5293610GmogCn','static','await'];a0_0x2277=function(){return _0x482b34;};return a0_0x2277();}function modelKeywordDefence(_0x7c622f){const _0x4dce0f=a0_0x57ee35;let _0x21be08=[_0x4dce0f(0x1ce),'double','int',_0x4dce0f(0x1d9),_0x4dce0f(0x1d2),_0x4dce0f(0x1f2),_0x4dce0f(0x1be),'dynamic','implements',_0x4dce0f(0x207),'as',_0x4dce0f(0x1e5),'import',_0x4dce0f(0x1db),_0x4dce0f(0x1d5),'enum','in',_0x4dce0f(0x1bf),_0x4dce0f(0x1b1),'export',_0x4dce0f(0x1d6),'switch',_0x4dce0f(0x1dc),_0x4dce0f(0x1d4),'is',_0x4dce0f(0x1f3),'break',_0x4dce0f(0x1c9),_0x4dce0f(0x1bd),_0x4dce0f(0x1b8),_0x4dce0f(0x1ee),_0x4dce0f(0x1ec),'mixin',_0x4dce0f(0x1c5),_0x4dce0f(0x1d7),_0x4dce0f(0x1bc),'new',_0x4dce0f(0x203),_0x4dce0f(0x1f0),'final',_0x4dce0f(0x1b5),_0x4dce0f(0x1fd),_0x4dce0f(0x1e8),_0x4dce0f(0x1b3),'on',_0x4dce0f(0x1e9),_0x4dce0f(0x1f5),_0x4dce0f(0x1d3),_0x4dce0f(0x1f4),_0x4dce0f(0x200),_0x4dce0f(0x20c),_0x4dce0f(0x1b9),_0x4dce0f(0x1cd),_0x4dce0f(0x1f6),_0x4dce0f(0x1fa),_0x4dce0f(0x1cf),_0x4dce0f(0x1c8),_0x4dce0f(0x1ba),_0x4dce0f(0x1de),'hide',_0x4dce0f(0x1c0),_0x4dce0f(0x1d0),'do','if',_0x4dce0f(0x1d1),_0x4dce0f(0x1e1)];if(_0x21be08[_0x4dce0f(0x1b7)](_0x7c622f)||/^\d/['test'](_0x7c622f))return _0x4dce0f(0x1c3)+(0x0,js_utils_plus_1[_0x4dce0f(0x1f9)])(_0x7c622f);return(0x0,js_utils_plus_1[_0x4dce0f(0x20e)])(_0x7c622f);}function a0_0x5c59(_0x4003fd,_0x1bd013){_0x4003fd=_0x4003fd-0x1ae;const _0x22775e=a0_0x2277();let _0x5c599c=_0x22775e[_0x4003fd];return _0x5c599c;}function resolveClassName(_0x31f731,_0x1d54e5,_0x5bc81d){const _0x55ce9b=a0_0x57ee35,_0x11326e=Object[_0x55ce9b(0x1e3)](_0x1d54e5)[_0x55ce9b(0x202)](([_0x1b8eba,_0x1f3e39])=>_0x1b8eba+'='+typeof _0x1f3e39)[_0x55ce9b(0x1ef)]('&');if(!_0x5bc81d[_0x31f731])return _0x5bc81d[_0x31f731]=_0x11326e,_0x31f731;if(_0x5bc81d[_0x31f731]&&_0x5bc81d[_0x31f731]==_0x11326e)return'';let _0x1a3f1e=0x2,_0x37a90b=''+_0x31f731+_0x1a3f1e;while(_0x5bc81d[_0x37a90b]&&_0x5bc81d[_0x37a90b]!==_0x11326e){_0x1a3f1e++,_0x37a90b=''+_0x31f731+_0x1a3f1e;}if(!_0x5bc81d[_0x37a90b])_0x5bc81d[_0x37a90b]=_0x11326e;return _0x37a90b;}function jsonToDart(_0x36b8d8,_0x5867f0,_0x418a7f,_0x5c0b37,_0x1deeb3,_0x1146ca=!![]){const _0x2da39b=a0_0x57ee35,_0x8675e6=_0x1146ca?{}:jsonToDart[_0x2da39b(0x1fe)];if(_0x1146ca)jsonToDart['_classMap']=_0x8675e6;const _0x2c52e2=(0x0,js_utils_plus_1[_0x2da39b(0x1f9)])((0x0,js_utils_plus_1[_0x2da39b(0x20e)])(_0x5867f0));_0x5867f0=resolveClassName(_0x2c52e2,_0x36b8d8,_0x8675e6);if(!_0x5867f0)return{'context':''};let _0x2048b7=[],_0x310d83=[],_0xc093cf=[],_0x4e25be=[],_0x298268=[],_0x1d60e8=[];_0x2048b7[_0x2da39b(0x1b0)](_0x2da39b(0x1ed)+_0x5867f0+_0x418a7f+'\x20{'),_0xc093cf[_0x2da39b(0x1b0)]('\x20\x20'+_0x5867f0+_0x418a7f+'({\x0a'),_0x4e25be['push']('\x20\x20'+_0x5867f0+_0x418a7f+_0x2da39b(0x1c1)),_0x298268[_0x2da39b(0x1b0)](_0x2da39b(0x1b4));for(const [_0x553cd3,_0x4fc4ab]of Object['entries'](_0x36b8d8)){let _0x372a59='\x27'+_0x553cd3+'\x27',_0x3221b0=modelKeywordDefence(_0x553cd3);const _0x292a14=(0x0,js_utils_plus_1['uppercaseFirst'])((0x0,js_utils_plus_1[_0x2da39b(0x20e)])(_0x553cd3)),{type:_0x314642,typeTo:_0x337150,typeFrom:_0xce57,subLines:_0x248623}=modelTypeGenerator(_0x553cd3,_0x4fc4ab,_0x292a14,_0x418a7f,_0x5c0b37,_0x1deeb3);if(_0x248623)_0x1d60e8[_0x2da39b(0x1b0)](_0x248623);_0xc093cf[_0x2da39b(0x1b0)]('\x20\x20\x20\x20this.'+_0x3221b0+',\x0a'),_0x310d83['push']('\x20\x20'+_0x314642+(_0x5c0b37?'?':'')+'\x20'+_0x3221b0+';\x0a'),_0x4e25be[_0x2da39b(0x1b0)](_0x2da39b(0x1eb)+_0x3221b0+'\x20=\x20'+_0xce57(_0x2da39b(0x1f7)+_0x372a59+']')+';\x0a'),_0x298268[_0x2da39b(0x1b0)]('\x20\x20\x20\x20'+_0x372a59+':\x20'+_0x337150(_0x3221b0)+',\x0a');}_0xc093cf['push'](_0x2da39b(0x1cb)),_0x4e25be[_0x2da39b(0x1b0)](_0x2da39b(0x1df)),_0x298268[_0x2da39b(0x1b0)]('\x20\x20};'),_0x2048b7[_0x2da39b(0x1b0)](_0x310d83['join']('')),_0x2048b7[_0x2da39b(0x1b0)](_0xc093cf['join']('')),_0x2048b7['push'](_0x4e25be[_0x2da39b(0x1ef)]('')),_0x2048b7[_0x2da39b(0x1b0)](_0x298268[_0x2da39b(0x1ef)]('')),_0x2048b7[_0x2da39b(0x1b0)]('}\x0a'),_0x2048b7['push'](_0x1d60e8[_0x2da39b(0x1ef)](''));const _0x5a5c96=_0x1146ca?_0x2048b7[_0x2da39b(0x1ef)]('\x0a')['replace'](/[\n\r]?$/g,''):_0x2048b7[_0x2da39b(0x1ef)]('\x0a');return{'context':_0x5a5c96,'className':_0x5867f0};}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
'use strict';const
|
|
2
|
+
'use strict';function a1_0x3946(){const _0x3c08d4=['numparse','dart模型输出路径,默认\x20lib/models','opts','lib/models','-o,\x20--output\x20<dir>','name','./core/json2dart','cwd','json','2604296ADfPoI','log','-\x20执行文件:','commander','5185692CKMIjy','parse','41bCVafS','writeFileSync','使用num数据类型而不是double/int','output','join','144DZMocu','default','48975EWtCyU','js-utils-plus','dir','10owxltz','7XtZiSB','.dart','excludes','suffix','json文件夹路径,默认\x20.json_models/','13863078IIdfxp','需要排除的文件或文件夹,可指定多个文件','listFilesRecursively','289552URPeKU','62444JTUSeJ','jsonToDart','assign','-d,\x20--dir\x20<dir>','--nullsafety','option','__className','-s,\x20--suffix\x20<value>','readFileSync','__importDefault','.json_models/','6894481XtYksB','forEach','是否启用空安全'];a1_0x3946=function(){return _0x3c08d4;};return a1_0x3946();}const a1_0x38c886=a1_0x1b8e;(function(_0x2c321d,_0x3b4b1c){const _0x2abb16=a1_0x1b8e,_0x215057=_0x2c321d();while(!![]){try{const _0x369ab7=-parseInt(_0x2abb16(0x12d))/0x1*(-parseInt(_0x2abb16(0x141))/0x2)+-parseInt(_0x2abb16(0x12b))/0x3+-parseInt(_0x2abb16(0x127))/0x4+parseInt(_0x2abb16(0x134))/0x5*(-parseInt(_0x2abb16(0x132))/0x6)+-parseInt(_0x2abb16(0x138))/0x7*(-parseInt(_0x2abb16(0x140))/0x8)+parseInt(_0x2abb16(0x13d))/0x9+parseInt(_0x2abb16(0x137))/0xa*(parseInt(_0x2abb16(0x14c))/0xb);if(_0x369ab7===_0x3b4b1c)break;else _0x215057['push'](_0x215057['shift']());}catch(_0x577768){_0x215057['push'](_0x215057['shift']());}}}(a1_0x3946,0xd4153));function a1_0x1b8e(_0x3e0d5f,_0x594fca){_0x3e0d5f=_0x3e0d5f-0x127;const _0x394662=a1_0x3946();let _0x1b8e7c=_0x394662[_0x3e0d5f];return _0x1b8e7c;}var __importDefault=this&&this[a1_0x38c886(0x14a)]||function(_0x20ffc2){return _0x20ffc2&&_0x20ffc2['__esModule']?_0x20ffc2:{'default':_0x20ffc2};};Object['defineProperty'](exports,'__esModule',{'value':!![]});const json2dart_1=require(a1_0x38c886(0x155)),js_utils_plus_1=require(a1_0x38c886(0x135)),commander_1=require(a1_0x38c886(0x12a)),path_1=__importDefault(require('path')),program=new commander_1['Command'](),_path=process[a1_0x38c886(0x156)]();program['option'](a1_0x38c886(0x144),a1_0x38c886(0x13c))[a1_0x38c886(0x146)](a1_0x38c886(0x153),a1_0x38c886(0x150))['option'](a1_0x38c886(0x148),'自定义dart模型类名后缀,\x20如\x20Entity、Model')[a1_0x38c886(0x146)]('-e,\x20--excludes\x20<value...>',a1_0x38c886(0x13e))[a1_0x38c886(0x146)]('--numparse',a1_0x38c886(0x12f))[a1_0x38c886(0x146)](a1_0x38c886(0x145),a1_0x38c886(0x14e)),program[a1_0x38c886(0x12c)]();const options=Object[a1_0x38c886(0x143)]({'dir':a1_0x38c886(0x14b),'output':a1_0x38c886(0x152),'suffix':''},program[a1_0x38c886(0x151)]());function run(){const _0x3e7ccd=a1_0x38c886,_0x1a497b=path_1[_0x3e7ccd(0x133)]['join'](_path,options[_0x3e7ccd(0x136)]),_0x5d0c6b=(0x0,js_utils_plus_1[_0x3e7ccd(0x13f)])(_0x1a497b,_0x3e7ccd(0x157),options[_0x3e7ccd(0x13a)]||[]);console[_0x3e7ccd(0x128)](new Array(0x50)[_0x3e7ccd(0x131)]('-')),_0x5d0c6b[_0x3e7ccd(0x14d)](function(_0xa7ebb7){const _0x823c08=_0x3e7ccd,_0x2bdfea=(0x0,js_utils_plus_1[_0x823c08(0x149)])(_0xa7ebb7,!![]);if(!_0x2bdfea){console['error'](_0x823c08(0x129)+_0xa7ebb7);return;}console[_0x823c08(0x128)](_0x823c08(0x129)+_0xa7ebb7);const _0x1ceb2e=path_1['default'][_0x823c08(0x12c)](_0xa7ebb7);let _0x19062c=_0x2bdfea[_0x823c08(0x147)]||_0x1ceb2e[_0x823c08(0x154)];if(_0x2bdfea[_0x823c08(0x147)])delete _0x2bdfea[_0x823c08(0x147)];const {context:_0x2c1de0}=(0x0,json2dart_1[_0x823c08(0x142)])(_0x2bdfea,_0x19062c,options[_0x823c08(0x13b)],options['nullsafety'],options[_0x823c08(0x14f)]),_0x44015d=path_1[_0x823c08(0x133)][_0x823c08(0x131)](_path,options[_0x823c08(0x130)],_0x1ceb2e['name']+_0x823c08(0x139));(0x0,js_utils_plus_1[_0x823c08(0x12e)])(_0x44015d,_0x2c1de0);});}run();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json2dart-generator",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "JSON 转 Dart Model 类构建工具",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"dev": "tsc -w",
|
|
11
|
-
"test": "tsc && node dist/index.js -d ./.json_models -o ./models --nullsafety",
|
|
11
|
+
"test": "tsc && node dist/index.js -d ./.json_models -o ./models --nullsafety -s Entity",
|
|
12
12
|
"build": "rimraf dist && tsc && javascript-obfuscator dist --output dist"
|
|
13
13
|
},
|
|
14
14
|
"author": "evan.lin",
|