KMAliasLightParser.swift 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. //
  2. // KMAliasLightParser.swift
  3. // Cisdem PDFMaster
  4. //
  5. // Created by wanjun on 2022/12/21.
  6. //
  7. import Cocoa
  8. class KMAliasLightParser: KMBaseParser {
  9. func startParse() -> KMAliasLight {
  10. self.fileName = "alias-light"
  11. self.fileType = "json"
  12. return aliasLightParser(self.jsonParser)
  13. }
  14. func aliasLightParser(_ jsonData: [String: Any]) -> KMAliasLight {
  15. let data = jsonData
  16. let allKey = data.keys
  17. let aliasLightModel = KMAliasLight.init()
  18. if allKey.contains("spacing") {
  19. aliasLightModel.spacing = ["spacing" : spacingNodeParser((data["spacing"] as! [String : Any]))]
  20. }
  21. if allKey.contains("color") {
  22. aliasLightModel.color = ["color" : colorNodeParser((data["color"] as! [String : Any]))]
  23. }
  24. if allKey.contains("radius") {
  25. aliasLightModel.radius = ["radius" : radiusNodeParser((data["radius"] as! [String : Any]))]
  26. }
  27. if allKey.contains("text") {
  28. aliasLightModel.text = ["text" : textNodeParser((data["text"] as! [String : Any]))]
  29. }
  30. if allKey.contains("shadow") {
  31. aliasLightModel.shadow = ["shadow" : shadowNodeParser((data["shadow"] as! [String : Any]))]
  32. }
  33. return aliasLightModel
  34. }
  35. // MARK: spacing
  36. func spacingNodeParser(_ jsonData: [String: Any]) -> KMAliasLight_spacing {
  37. let allKey = jsonData.keys
  38. let model = KMAliasLight_spacing.init()
  39. if allKey.contains("base") {
  40. model.base = ["base" : spacingSubNodeParser(jsonData["base"] as! [String : Any])]
  41. }
  42. if allKey.contains("tree") {
  43. model.tree = ["tree" : numberNodeParser(jsonData["tree"] as! [String : Any])]
  44. }
  45. return model
  46. }
  47. // MARK: color
  48. func colorNodeParser(_ jsonData: [String: Any]) -> KMAliasLight_color {
  49. let allKey = jsonData.keys
  50. let model = KMAliasLight_color.init()
  51. if allKey.contains("btn") {
  52. model.btn = ["btn" : controlNodeParser(jsonData["btn"] as! [String : Any])]
  53. }
  54. if allKey.contains("sys") {
  55. model.sys = ["sys" : controlNodeParser(jsonData["sys"] as! [String : Any])]
  56. }
  57. if allKey.contains("item-state") {
  58. model.item_state = ["item-state" : controlNodeParser(jsonData["item-state"] as! [String : Any])]
  59. }
  60. if allKey.contains("field") {
  61. model.field = ["field" : attributeNodeParser(jsonData["field"] as! [String : Any])]
  62. }
  63. if allKey.contains("slider") {
  64. model.slider = ["slider" : attributeNodeParser(jsonData["slider"] as! [String : Any])]
  65. }
  66. if allKey.contains("icon") {
  67. model.icon = ["icon" : color_icon_baseParser(jsonData["icon"] as! [String : Any])]
  68. }
  69. if allKey.contains("badge") {
  70. let subData = jsonData["badge"] as! [String : Any]
  71. let subKeys = subData.keys
  72. let submodel = KMAliasLight_control.init()
  73. if subKeys.contains("red") {
  74. submodel.red = ["red" : attributeNodeParser2(subData["red"] as! [String : Any])]
  75. }
  76. model.badge = ["badge" : submodel]
  77. }
  78. return model
  79. }
  80. func color_icon_baseParser(_ jsonData: [String: Any]) -> KMAliasLight_attribute {
  81. let allKey = jsonData.keys
  82. let model = KMAliasLight_attribute.init()
  83. if allKey.contains("neutral") {
  84. model.neutral = ["neutral" : color_icon_base_neutralParser(jsonData["neutral"] as! [String : Any])]
  85. }
  86. if allKey.contains("brand") {
  87. model.brand = ["brand" : valueTypeParser(jsonData["brand"] as! [String : Any])]
  88. }
  89. if allKey.contains("accent") {
  90. model.accent = ["accent" : valueTypeParser(jsonData["accent"] as! [String : Any])]
  91. }
  92. if allKey.contains("state") {
  93. model.state = ["state" : stateParser(jsonData["state"] as! [String : Any])]
  94. }
  95. if allKey.contains("anti") {
  96. model.anti = ["anti" : stateParser(jsonData["anti"] as! [String : Any])]
  97. }
  98. return model
  99. }
  100. func color_icon_base_neutralParser(_ jsonData: [String: Any]) -> KMAliasLight_state {
  101. let allKey = jsonData.keys
  102. let model = KMAliasLight_state.init()
  103. if allKey.contains("norm") {
  104. model.norm = ["norm" : lvParser(jsonData["norm"] as! [String : Any])]
  105. }
  106. if allKey.contains("sel") {
  107. model.sel = ["sel" : valueTypeParser(jsonData["sel"] as! [String : Any])]
  108. }
  109. if allKey.contains("dis") {
  110. model.dis = ["dis" : valueTypeParser(jsonData["dis"] as! [String : Any])]
  111. }
  112. return model
  113. }
  114. // MARK: radius
  115. func radiusNodeParser(_ jsonData: [String: Any]) -> KMAliasLight_radius {
  116. let allKey = jsonData.keys
  117. let model = KMAliasLight_radius.init()
  118. if allKey.contains("base") {
  119. model.base = ["base" : sizeParser(jsonData["base"] as! [String : Any])]
  120. }
  121. if allKey.contains("fullround-btn") {
  122. model.fullround_btn = ["fullround-btn" : sizeParser(jsonData["fullround-btn"] as! [String : Any])]
  123. }
  124. return model
  125. }
  126. // MARK: text
  127. func textNodeParser(_ jsonData: [String: Any]) -> KMAliasLight_text {
  128. let allKey = jsonData.keys
  129. let model = KMAliasLight_text.init()
  130. if allKey.contains("mac") {
  131. let subData = jsonData["mac"] as! [String : Any]
  132. let subKeys = subData.keys
  133. let submodel = KMAliasLight_attribute.init()
  134. if subKeys.contains("footnote") {
  135. submodel.footnote = ["footnote" : attributeNodeParser2(subData["footnote"] as! [String : Any])]
  136. }
  137. if subKeys.contains("body") {
  138. submodel.body = ["body" : sizeParser(subData["body"] as! [String : Any])]
  139. }
  140. if subKeys.contains("title") {
  141. submodel.title = ["title" : sizeParser(subData["title"] as! [String : Any])]
  142. }
  143. model.mac = ["fullround-btn" : submodel]
  144. }
  145. if allKey.contains("win") {
  146. let subData = jsonData["win"] as! [String : Any]
  147. let subKeys = subData.keys
  148. let submodel = KMAliasLight_attribute.init()
  149. if subKeys.contains("footnote") {
  150. submodel.footnote = ["footnote" : attributeNodeParser2(subData["footnote"] as! [String : Any])]
  151. }
  152. if subKeys.contains("body") {
  153. submodel.body = ["body" : sizeParser(subData["body"] as! [String : Any])]
  154. }
  155. if subKeys.contains("title") {
  156. submodel.title = ["title" : sizeParser(subData["title"] as! [String : Any])]
  157. }
  158. model.win = ["fullround-btn" : submodel]
  159. }
  160. return model
  161. }
  162. // MARK: shadow
  163. func shadowNodeParser(_ jsonData: [String: Any]) -> KMAliasLight_shadow {
  164. let allKey = jsonData.keys
  165. let model = KMAliasLight_shadow.init()
  166. if allKey.contains("neutral") {
  167. model.neutral = ["neutral" : sizeParser(jsonData["neutral"] as! [String : Any])]
  168. }
  169. if allKey.contains("accent") {
  170. model.accent = ["accent" : sizeParser(jsonData["accent"] as! [String : Any])]
  171. }
  172. if allKey.contains("error") {
  173. model.error = ["error" : sizeParser(jsonData["error"] as! [String : Any])]
  174. }
  175. return model
  176. }
  177. // MARK: - sub node
  178. func controlNodeParser(_ jsonData: [String: Any]) -> KMAliasLight_control {
  179. let allKey = jsonData.keys
  180. let model = KMAliasLight_control.init()
  181. if allKey.contains("cta") {
  182. model.cta = ["cta" : attributeNodeParser(jsonData["cta"] as! [String : Any])]
  183. }
  184. if allKey.contains("brand") {
  185. model.brand = ["brand" : attributeNodeParser(jsonData["brand"] as! [String : Any])]
  186. }
  187. if allKey.contains("sec") {
  188. let subData = jsonData["sec"] as! [String : Any]
  189. let subKeys = subData.keys
  190. let submodel = KMAliasLight_attribute.init()
  191. if subKeys.contains("border-color") {
  192. submodel.border_color = ["border-color" : valueTypeParser(subData["border-color"] as! [String : Any])]
  193. }
  194. if subKeys.contains("bg") {
  195. submodel.bg = ["bg" : stateParser(subData["bg"] as! [String : Any])]
  196. }
  197. if subKeys.contains("text") {
  198. submodel.text = ["text" : stateParser(subData["text"] as! [String : Any])]
  199. }
  200. model.sec = ["sec" : submodel]
  201. }
  202. if allKey.contains("icon-fill") {
  203. model.icon_fill = ["icon-fill" : attributeNodeParser(jsonData["icon-fill"] as! [String : Any])]
  204. }
  205. if allKey.contains("ghost") {
  206. model.ghost = ["ghost" : attributeNodeParser(jsonData["ghost"] as! [String : Any])]
  207. }
  208. if allKey.contains("link") {
  209. model.link = ["link" : attributeNodeParser(jsonData["link"] as! [String : Any])]
  210. }
  211. if allKey.contains("upgrade") {
  212. model.upgrade = ["upgrade" : attributeNodeParser(jsonData["upgrade"] as! [String : Any])]
  213. }
  214. if allKey.contains("text") {
  215. model.text = ["text" : attributeNodeParser(jsonData["text"] as! [String : Any])]
  216. }
  217. if allKey.contains("border") {
  218. let subData = jsonData["border"] as! [String : Any]
  219. let subKeys = subData.keys
  220. let submodel = KMAliasLight_attribute.init()
  221. if subKeys.contains("error") {
  222. submodel.error = ["error" : valueTypeParser(subData["error"] as! [String : Any])]
  223. }
  224. if subKeys.contains("neutral") {
  225. submodel.neutral = ["neutral" : stateParser(subData["neutral"] as! [String : Any])]
  226. }
  227. if subKeys.contains("accent") {
  228. submodel.accent = ["accent" : stateParser(subData["accent"] as! [String : Any])]
  229. }
  230. model.border = ["border" : submodel]
  231. }
  232. if allKey.contains("layout") {
  233. let subData = jsonData["layout"] as! [String : Any]
  234. let subKeys = subData.keys
  235. let submodel = KMAliasLight_attribute.init()
  236. if subKeys.contains("bg") {
  237. submodel.bg = ["bg" : stateParser(subData["bg"] as! [String : Any])]
  238. }
  239. if subKeys.contains("mg") {
  240. submodel.mg = ["mg" : valueTypeParser(subData["mg"] as! [String : Any])]
  241. }
  242. if subKeys.contains("fg") {
  243. submodel.fg = ["fg" : stateParser(subData["fg"] as! [String : Any])]
  244. }
  245. if subKeys.contains("dark") {
  246. submodel.dark = ["dark" : stateParser(subData["dark"] as! [String : Any])]
  247. }
  248. if subKeys.contains("state") {
  249. submodel.state = ["state" : stateParser(subData["state"] as! [String : Any])]
  250. }
  251. if subKeys.contains("anti") {
  252. submodel.anti = ["anti" : valueTypeParser(subData["anti"] as! [String : Any])]
  253. }
  254. if subKeys.contains("accent") {
  255. submodel.accent = ["accent" : valueTypeParser(subData["accent"] as! [String : Any])]
  256. }
  257. if subKeys.contains("brand") {
  258. submodel.brand = ["brand" : valueTypeParser(subData["brand"] as! [String : Any])]
  259. }
  260. if subKeys.contains("divider") {
  261. submodel.divider = ["divider" : valueTypeParser(subData["divider"] as! [String : Any])]
  262. }
  263. model.layout = ["layout" : submodel]
  264. }
  265. if allKey.contains("sel") {
  266. model.sel = ["sel" : attributeNodeParser(jsonData["sel"] as! [String : Any])]
  267. }
  268. if allKey.contains("hov") {
  269. model.hov = ["hov" : attributeNodeParser2(jsonData["hov"] as! [String : Any])]
  270. }
  271. if allKey.contains("red") {
  272. model.red = ["red" : attributeNodeParser(jsonData["red"] as! [String : Any])]
  273. }
  274. return model
  275. }
  276. func spacingSubNodeParser(_ jsonData: [String: Any]) -> KMAliasLight_attribute {
  277. let allKey = jsonData.keys
  278. let model = KMAliasLight_attribute.init()
  279. if allKey.contains("element") {
  280. model.element = ["element" : numberNodeParser(jsonData["element"] as! [String : Any])]
  281. }
  282. if allKey.contains("module") {
  283. model.module = ["module" : numberNodeParser(jsonData["module"] as! [String : Any])]
  284. }
  285. return model
  286. }
  287. func attributeNodeParser(_ jsonData: [String: Any]) -> KMAliasLight_attribute {
  288. let allKey = jsonData.keys
  289. let model = KMAliasLight_attribute.init()
  290. if allKey.contains("bg") {
  291. model.bg = ["bg" : stateParser(jsonData["bg"] as! [String : Any])]
  292. }
  293. if allKey.contains("text") {
  294. model.text = ["text" : stateParser(jsonData["text"] as! [String : Any])]
  295. }
  296. if allKey.contains("border") {
  297. model.border = ["border" : stateParser(jsonData["border"] as! [String : Any])]
  298. }
  299. if allKey.contains("anti") {
  300. model.anti = ["anti" : stateParser(jsonData["anti"] as! [String : Any])]
  301. }
  302. if allKey.contains("accent") {
  303. model.accent = ["accent" : stateParser(jsonData["accent"] as! [String : Any])]
  304. }
  305. if allKey.contains("neutral") {
  306. model.neutral = ["neutral" : stateParser(jsonData["neutral"] as! [String : Any])]
  307. }
  308. if allKey.contains("brand") {
  309. model.brand = ["brand" : stateParser(jsonData["brand"] as! [String : Any])]
  310. }
  311. if allKey.contains("error") {
  312. model.error = ["error" : stateParser(jsonData["error"] as! [String : Any])]
  313. }
  314. if allKey.contains("mg") {
  315. model.mg = ["mg" : valueTypeParser(jsonData["mg"] as! [String : Any])]
  316. }
  317. if allKey.contains("fg") {
  318. model.fg = ["fg" : stateParser(jsonData["fg"] as! [String : Any])]
  319. }
  320. if allKey.contains("dark") {
  321. model.dark = ["dark" : stateParser(jsonData["dark"] as! [String : Any])]
  322. }
  323. if allKey.contains("state") {
  324. model.state = ["state" : stateParser(jsonData["state"] as! [String : Any])]
  325. }
  326. if allKey.contains("bg-text") {
  327. model.bg_text = ["bg-text" : stateParser(jsonData["bg-text"] as! [String : Any])]
  328. }
  329. if allKey.contains("track") {
  330. model.track = ["track" : stateParser(jsonData["track"] as! [String : Any])]
  331. }
  332. if allKey.contains("track-filled") {
  333. model.track_filled = ["track-filled" : stateParser(jsonData["track-filled"] as! [String : Any])]
  334. }
  335. if allKey.contains("knob") {
  336. model.knob = ["knob" : stateParser(jsonData["knob"] as! [String : Any])]
  337. }
  338. return model
  339. }
  340. func attributeNodeParser2(_ jsonData: [String: Any]) -> KMAliasLight_attribute {
  341. let allKey = jsonData.keys
  342. let model = KMAliasLight_attribute.init()
  343. if allKey.contains("bg") {
  344. model.bg = ["bg" : valueTypeParser(jsonData["bg"] as! [String : Any])]
  345. }
  346. if allKey.contains("footnote") {
  347. model.footnote = ["footnote" : valueTypeParser(jsonData["footnote"] as! [String : Any])]
  348. }
  349. return model
  350. }
  351. func stateParser(_ jsonData: [String: Any]) -> KMAliasLight_state {
  352. let allKey = jsonData.keys
  353. let model = KMAliasLight_state.init()
  354. if allKey.contains("norm") {
  355. model.norm = ["norm" : valueTypeParser(jsonData["norm"] as! [String : Any])]
  356. }
  357. if allKey.contains("hov") {
  358. model.hov = ["hov" : valueTypeParser(jsonData["hov"] as! [String : Any])]
  359. }
  360. if allKey.contains("act") {
  361. model.act = ["act" : valueTypeParser(jsonData["act"] as! [String : Any])]
  362. }
  363. if allKey.contains("dis") {
  364. model.dis = ["dis" : valueTypeParser(jsonData["dis"] as! [String : Any])]
  365. }
  366. if allKey.contains("def") {
  367. model.def = ["def" : valueTypeParser(jsonData["def"] as! [String : Any])]
  368. }
  369. if allKey.contains("lv1") {
  370. model.lv1 = ["lv1" : valueTypeParser(jsonData["lv1"] as! [String : Any])]
  371. }
  372. if allKey.contains("lv2") {
  373. model.lv2 = ["lv2" : valueTypeParser(jsonData["lv2"] as! [String : Any])]
  374. }
  375. if allKey.contains("lv3") {
  376. model.lv3 = ["lv3" : valueTypeParser(jsonData["lv3"] as! [String : Any])]
  377. }
  378. if allKey.contains("home") {
  379. model.home = ["home" : valueTypeParser(jsonData["home"] as! [String : Any])]
  380. }
  381. if allKey.contains("view") {
  382. model.view = ["view" : valueTypeParser(jsonData["view"] as! [String : Any])]
  383. }
  384. if allKey.contains("tabbar") {
  385. model.tabbar = ["tabbar" : valueTypeParser(jsonData["tabbar"] as! [String : Any])]
  386. }
  387. if allKey.contains("light") {
  388. model.light = ["light" : valueTypeParser(jsonData["light"] as! [String : Any])]
  389. }
  390. if allKey.contains("light-dis") {
  391. model.light_dis = ["light-dis" : valueTypeParser(jsonData["light-dis"] as! [String : Any])]
  392. }
  393. if allKey.contains("dark") {
  394. model.dark = ["dark" : valueTypeParser(jsonData["dark"] as! [String : Any])]
  395. }
  396. if allKey.contains("bg") {
  397. model.bg = ["bg" : valueTypeParser(jsonData["bg"] as! [String : Any])]
  398. }
  399. if allKey.contains("note") {
  400. model.note = ["note" : valueTypeParser(jsonData["note"] as! [String : Any])]
  401. }
  402. if allKey.contains("info") {
  403. model.info = ["info" : valueTypeParser(jsonData["info"] as! [String : Any])]
  404. }
  405. if allKey.contains("error") {
  406. model.error = ["error" : valueTypeParser(jsonData["error"] as! [String : Any])]
  407. }
  408. if allKey.contains("warning") {
  409. model.warning = ["warning" : valueTypeParser(jsonData["warning"] as! [String : Any])]
  410. }
  411. if allKey.contains("focus") {
  412. model.focus = ["focus" : valueTypeParser(jsonData["focus"] as! [String : Any])]
  413. }
  414. if allKey.contains("sel") {
  415. model.sel = ["sel" : valueTypeParser(jsonData["sel"] as! [String : Any])]
  416. }
  417. return model
  418. }
  419. func stateParser2(_ jsonData: [String: Any]) -> KMAliasLight_state {
  420. let allKey = jsonData.keys
  421. let model = KMAliasLight_state.init()
  422. if allKey.contains("norm") {
  423. model.norm = ["norm" : lvParser(jsonData["norm"] as! [String : Any])]
  424. }
  425. return model
  426. }
  427. func lvParser(_ jsonData: [String: Any]) -> KMAliasLight_lv {
  428. let allKey = jsonData.keys
  429. let model = KMAliasLight_lv.init()
  430. if allKey.contains("lv1") {
  431. model.lv1 = ["lv1" : valueTypeParser(jsonData["lv1"] as! [String : Any])]
  432. }
  433. if allKey.contains("lv2") {
  434. model.lv2 = ["lv2" : valueTypeParser(jsonData["lv2"] as! [String : Any])]
  435. }
  436. if allKey.contains("lv3") {
  437. model.lv3 = ["lv3" : valueTypeParser(jsonData["lv3"] as! [String : Any])]
  438. }
  439. return model
  440. }
  441. func numberNodeParser(_ jsonData: [String: Any]) -> KMAliasLight_number {
  442. let allKey = jsonData.keys
  443. let model = KMAliasLight_number.init()
  444. if allKey.contains("0") {
  445. model.number0 = ["0" : valueTypeParser(jsonData["0"] as! [String : Any])]
  446. }
  447. if allKey.contains("1") {
  448. model.number1 = ["1" : valueTypeParser(jsonData["1"] as! [String : Any])]
  449. }
  450. if allKey.contains("2") {
  451. model.number2 = ["2" : valueTypeParser(jsonData["2"] as! [String : Any])]
  452. }
  453. if allKey.contains("4") {
  454. model.number4 = ["4" : valueTypeParser(jsonData["4"] as! [String : Any])]
  455. }
  456. if allKey.contains("6") {
  457. model.number6 = ["6" : valueTypeParser(jsonData["6"] as! [String : Any])]
  458. }
  459. if allKey.contains("8") {
  460. model.number8 = ["8" : valueTypeParser(jsonData["8"] as! [String : Any])]
  461. }
  462. if allKey.contains("12") {
  463. model.number12 = ["12" : valueTypeParser(jsonData["12"] as! [String : Any])]
  464. }
  465. if allKey.contains("16") {
  466. model.number16 = ["16" : valueTypeParser(jsonData["16"] as! [String : Any])]
  467. }
  468. if allKey.contains("24") {
  469. model.number24 = ["24" : valueTypeParser(jsonData["24"] as! [String : Any])]
  470. }
  471. if allKey.contains("32") {
  472. model.number32 = ["32" : valueTypeParser(jsonData["32"] as! [String : Any])]
  473. }
  474. if allKey.contains("40") {
  475. model.number40 = ["40" : valueTypeParser(jsonData["40"] as! [String : Any])]
  476. }
  477. if allKey.contains("56") {
  478. model.number56 = ["56" : valueTypeParser(jsonData["56"] as! [String : Any])]
  479. }
  480. if allKey.contains("64") {
  481. model.number64 = ["64" : valueTypeParser(jsonData["64"] as! [String : Any])]
  482. }
  483. if allKey.contains("80") {
  484. model.number80 = ["80" : valueTypeParser(jsonData["80"] as! [String : Any])]
  485. }
  486. if allKey.contains("88") {
  487. model.number88 = ["88" : valueTypeParser(jsonData["88"] as! [String : Any])]
  488. }
  489. return model
  490. }
  491. func sizeParser(_ jsonData: [String: Any]) -> KMAliasLight_size {
  492. let allKey = jsonData.keys
  493. let model = KMAliasLight_size.init()
  494. if allKey.contains("s") {
  495. model.s = ["s" : valueTypeParser(jsonData["s"] as! [String : Any])]
  496. }
  497. if allKey.contains("m") {
  498. model.m = ["m" : valueTypeParser(jsonData["m"] as! [String : Any])]
  499. }
  500. if allKey.contains("l") {
  501. model.l = ["l" : valueTypeParser(jsonData["l"] as! [String : Any])]
  502. }
  503. if allKey.contains("xs") {
  504. model.xs = ["xs" : valueTypeParser(jsonData["xs"] as! [String : Any])]
  505. }
  506. if allKey.contains("m-base") {
  507. model.m_base = ["m-base" : valueTypeParser(jsonData["m-base"] as! [String : Any])]
  508. }
  509. if allKey.contains("xl") {
  510. model.xl = ["xl" : valueTypeParser(jsonData["xl"] as! [String : Any])]
  511. }
  512. return model
  513. }
  514. func valueTypeParser(_ jsonData: [String: Any]) -> KMAliasLight_valueType {
  515. let allKey = jsonData.keys
  516. let model = KMAliasLight_valueType.init()
  517. if allKey.contains("value") {
  518. model.value = ["value" : jsonData["value"] as! String]
  519. }
  520. if allKey.contains("type") {
  521. model.type = ["type" : jsonData["type"] as! String]
  522. }
  523. return model
  524. }
  525. }
  526. // MARK: - Parser Action
  527. extension KMAliasLightParser {
  528. func startJSONParse() -> [String : Any] {
  529. self.fileName = "alias-light"
  530. self.fileType = "json"
  531. return self.jsonParser
  532. }
  533. }