好用的json轉(zhuǎn)model工具(Mac軟件)

一 、背景

model屬性定義是一個(gè)耗時(shí)易錯(cuò)的工作,如果能把這些枯燥易錯(cuò)的事交給工具來完成,會(huì)大大提高開發(fā)效率。

倉(cāng)庫(kù)地址:https://github.com/Xcoder1011/SKGenerateModelTool

二 、簡(jiǎn)介

SKGenerateModelTool

SKGenerateModelTool 具備以下優(yōu)點(diǎn):

  • 支持Objective-C / Swift / Dart / TypeScript
  • 支持通過URL鏈接或json字符串一鍵生成model文件
  • 兼容YYModel / MJExtension / HandyJSON解析
  • 支持字符串加密(可設(shè)置不同的密鑰,開發(fā)者可自行修改加密算法)
  • 支持自定義model父類名、自定義model前綴、自定義作者名、添加注釋
  • 支持代碼高亮(使用highlight.js
  • 支持導(dǎo)出TypeScript Interfaces
  • 支持自定義導(dǎo)出文件路徑
  • Flutter Model解析兼容了服務(wù)端返回string/int/double時(shí)數(shù)據(jù)類型混用的情況
  • 兼容服務(wù)端返回“id”字段
  • 支持類駝峰命名
  • Support Objective-C / Swift / Dart / TypeScript
  • Supports one-click generation of model files through URL links or json strings
  • Compatible with YYModel / MJExtension / HandyJSON analysis
  • Support string encryption (different keys can be set, developers can modify the encryption algorithm)
  • Support custom model superclass name, custom model prefix, custom author name, add comments
  • Support code highlighting(It uses highlight.js as it core)
  • Support for exporting TypeScript Interfaces
  • Support custom output folder path
  • Flutter model parsing is compatible with mixed data types when the server returns string / int / double
  • Compatible server returns "id" field
  • Supports hump naming

Usage

  • 方式一:直接下載軟件安裝 點(diǎn)擊下載
  • 方式二:下載代碼運(yùn)行

Objective-C

Objective-C

Swift

Swift

Dart

Dart

TypeScript Interfaces

TypeScript

字符串加密示例

encrypt.png

加密后的內(nèi)容添加到項(xiàng)目中(聲明和定義可以分別放.h和.m),因?yàn)榇a依賴SKEncryptString結(jié)構(gòu)體,所以需要導(dǎo)入頭文件SKEncryptHeader.h引用。

只需把此頭文件(SKEncryptHeader.h)加入到項(xiàng)目,并在pch文件中導(dǎo)入該頭文件即可使用;
Just add this header file (SKEncryptHeader.h) to the project and import the header file in the pch file to use;

SKEncryptHeader.png

加密后的數(shù)據(jù)申明:

/** 需要加密的重要字符,比如AppKey、AppSecret、AppID、數(shù)據(jù)庫(kù)密碼等 */
extern const SKEncryptString * const _3596508958;

/** Important characters that need to be encrypted, such as appkey, appsecret, appid, database password, etc */
extern const SKEncryptString * const _4038772756;

/** appkeyhdfoashiodfowehfowefjqwehgpqegpifhwappkey */
extern const SKEncryptString * const _3908173925;

定義:

/** 需要加密的重要字符,比如AppKey、AppSecret、AppID、數(shù)據(jù)庫(kù)密碼等 */
const SKEncryptString * const _3596508958 = &(SKEncryptString){
       .factor = (char)9,
       .value = (char[]){-125,-10,-22,-126,-52,-21,-113,-32,-54,-113,-59,-20,-115,-16,-18,-125,-19,-25,-126,-52,-21,-113,-57,-3,-115,-58,-52,-123,-42,-26,-116,-59,-2,-113,-52,-24,43,26,26,33,15,19,-119,-22,-21,43,26,26,57,15,9,24,15,30,-119,-22,-21,43,26,26,35,46,-119,-22,-21,-116,-1,-38,-116,-25,-60,-113,-48,-7,-113,-59,-20,-115,-54,-21,-115,-57,-29,0},
       .length = 83,
};

/** Important characters that need to be encrypted, such as appkey, appsecret, appid, database password, etc */
const SKEncryptString * const _4038772756 = &(SKEncryptString){
       .factor = (char)100,
       .value = (char[]){57,31,4,0,20,29,1,2,6,73,19,26,21,29,7,10,20,9,0,26,80,6,28,14,18,73,14,9,23,13,80,6,27,79,4,12,64,9,28,10,2,11,4,27,3,13,76,76,1,28,19,26,84,14,21,73,1,28,2,2,21,11,88,79,7,25,16,31,23,10,2,23,0,67,70,8,16,28,27,13,92,82,16,14,18,8,2,13,1,12,80,2,21,28,21,30,15,30,22,69,80,23,0,12,0},
       .length = 104,
       .key = (char[]){119,117,115,104,97,110,103,107,117,110,0},
       .kl = 10
};

/** appkeyhdfoashiodfowehfowefjqwehgpqegpifhwappkey */
const SKEncryptString * const _3908173925 = &(SKEncryptString){
       .factor = (char)50,
       .value = (char[]){4,20,23,14,1,30,13,0,1,10,5,20,13,13,8,1,2,8,18,1,15,3,11,16,0,2,13,20,19,2,13,3,23,20,1,0,21,13,1,13,19,6,21,20,12,0,29,0},
       .length = 47,
       .key = (char[]){98,99,96,0},
       .kl = 3
};

使用時(shí)

        if let string =  sk_OCString(_3596508958) {
            print("示例:解密后的數(shù)據(jù)為:\(string)")
        }
        if let string =  sk_OCString(_4038772756) {
            print("The decrypted data is:\(string)")
        }

Tip:本工具僅用到簡(jiǎn)單的XOR加密算法,開發(fā)者可自行下載項(xiàng)目進(jìn)行加密算法修改,另外也可直接下載項(xiàng)目里的dmg文件進(jìn)行安裝使用。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容