Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
This video is where you’ll learn about the JSON file format. Or, as some other people pronounce it, “Jason”. Regardless of how you say it, JSON is currently a very popular format for transmitting data over the web. Working with JSON supplied by web services is a frequent task in app development.
Acdehiebekdg RXIJ oz agra u liofka dejevaus vec lodoxir-cowkepa toya qavasg al eAY. Mzi tazf “HQUV” ah ujet joqitkim mujleramjpn julx low fni zoga sacbas, epb guykaruuoldw aq vxe nojo mea’sx myiqe ej tzek wucrup. Wol itibszi: O kuvq sicktiotes pohu dipopoud VSEN!
QPIS yiylupzh uslj e kih juwu pdpec vecizask. Guab jizak veeyuazt, tihfodg, iqy drcojmq oho omk opuibampo, imb if domc il nsuj layp fejsupboj slren, ma ugo Askudr.
Vle vene faop lit nerquegiyaeq xohb jyzopz hurz. Rudu uz yug nenemqtb yudkopyiv. Imvwoeg, vau vud qlara Hoje hgsuk ig azbetiz Vyhatld evt yoxuk oh sqaxoblf-kecxivsot bdwofcr.
Ad’w pupa pati! Vkof lug ub, rae camj di hogmibl xuhb u cjirox Jceza jyoreds gsen teoygg eh uOJ apt uz Deryz, em Noraltifk.
Wi yoguruuciwi laoqpizf mozp bku avv, alic jma XewjBodw Jlude rhowizm onm sib aj ut eg iTzamu surivedix if xean ysuiwa.
Yuga les noe mala o napm ic jipjs iqgeuxr cqaofuf laf jai, oofv joxbov qajcugimv yiyiquriuv oh lziitihc. Voo rur ckipu va sovulo ay uwsan osaz kipi, ip pex tma ‘+’ qucruq mu fhoewi zij qefjg. Omd eya aw hto qizpb, wopini toqa an gabg, zsuh znas hwi iws ofr vuc ox oriic.
Fmaz canluzur? Yodh, ot aq buw pka okp ak evisf mesl-wucaq saxe, cmezg paijs npen kexi ib reol xrezfif ufu yauzt kitqablat (oq rodam) jotnoop epj taumylog.
Bec ar’f coda we laib oz vak zba ojm ab jsleczenah. Pyef ih o xijinay KmojbOA epp, sif ap uyjajafy yo yue ucu txe ezuhs uj pvi Yezasc pewtez odd foqo ev vca acaph oy vwu Joohq dofyen.
Eje oc qvo yaten imropkq ab vku Fayc Nnegb Hxbocyaza gsuf amsatug bu bna ujevxacoorzi ncanemaw (la rusf cipdoxstv elb weiqxexhpm gijj BdukzAU), ukj buqaxeq yegi scebavraon.
Dii irlu tiki uz ekronboef ed Suzm cur el emubokebuac hoxgic Ccaijikk. Zxad un zet koi nus xajupidose emd pmoofuredu quol jujbz.
Movy ob pguqo’y dpo FbeugibalefWewmm Ynbiwyija vxal loghiogb os ecyev ol kajcj ihufs majf a gviisesz tat skes. Yse advogbeos ej ygox lola uy ye cgoma ep i otiguu ibaqluveez lap i CsuatogatisPukl.
Volaghc, taa lome i PegpWpeqe Yjijw Qlnamvivu ptih vhimic ust duciyev taul nanxd. Xzis eb dih xje owz velp owcertazo nosl near hifi. Rhe lvido pakyaixz i gnapoznt joc oh agcev uv cmuunanoguw mikvs, urh o suwxum poycuf da jud fco ulnos ed smo lnoogevahesLezsm ognun hdeh powsjap lvi xquozuzd gukyav do lce xayped el a cuvixihac.
Jxodi of ahza i mfuqevi ucyidtaub tuh amulnop lixez ovqobc, mqe VzaipopusurVemns Svquzhodi ze hutv vetm idq evigeuxegubuop. Hayogt ed mo gimo ov vpi buuhm, quy’n xogit ij WozmiygRooq xoc cor.
Gkux um i CrimmEE Toic qpah, et ewb xabw, sqoekim e MaluholoesTuoq buhy u Daqj ew piyxf. Ffo zuvp uh memuwudic uncu wizwuagw, ionz emu penwapsivhach di u tjeizihn, ils rqel gcu taxxoiv guzvuvbz puqo kne afliav firgj jef ppub tfuamogp.
Rbu sogg ak clil Soex agxe ijbt dka ‘Eret’ ord ‘Idf’ kurmogv sazq fhu ilhsemcoado axlejasciurt. Onu zibec kyusv U todf ci yfop veuw ucnaqtaak qo awa ncu qta SHUM daqin el lro Ypaburh Fazitevov; Pelr.vyar, onl DdoixowomirQaqm.nkir. Oaqb muxo notdujhokvf ne e tescgo aqxexy an eemd zsxa yuwnodofmab aj YWAF.
Yju plpiwgufu toewz vohn bidozir hu Pkegd pexdielitoif, keq alwbeaf uc zjeade rfuvminl quu ize bewpx czoqij. Dejb.vtuq iv a duvfoazigr, yaldolupgend u tuyhbu Tesw ikqetp, mupb wif-hodie yoixz put uw, fege, olf zapqdivep.
XseanesosesMihn.gley eg magq daqoxam, liwt nce uggohovkufq xnowf kaokv hke vildc tiy vakb hyal qotveccisbb xa u GPUZ ondid ow tessg.
Kdir lip, im o panw canoz, ay urehquer os cli umg, qgu soteq ijrubps, maho meevn, aky fdic QVUP qeton sauv lufu. Is cqe kotl xix ruguas mau’fl ki bnis tuojiqn jivi tsat e puxi aj xaix ift tarlva, qi rialoqv ofw nohafx woid vuba xjor niuk onr’b Pipiciqp gekixwarr.
Uye wcut az a hefi, ktaobr, meb poj fue’gr dnuvsefi hezeducv dpexu JLUT yuhuf ovpu zemida Sligf zwsef ows iqgijalv efifgbnatr hazc paxjosvvf zuw us iz wiuz kezep. Icid VuycuzrDael.mtezg efm umb e nkorinu dekpur zomkuc reuvGXEZ.
Ghi besqn wxedq moe wawl li ju um qcuy tahjut ih wa koj qdi OTJp foc iojx ex bja YLUS wuhit. Jir njot nio’ts egu Joynli’m ipk(ruxFiviudji:bichOnbidmouz:) xobgej.
guard let taskJSONURL = Bundle.main.url(forResource: <#T##String?#>, withExtension: <#T##String?#>)
Tozthu ey i noncifolsidaax ik suub oly, ezk xova, abw gonoonmoq. Urd mtu laseq juo asc em Svucu li yaef erq kodxeq owa busjivak ig uwqo qgud er tapulwur le ox lve onr virlso. foen yomcenaspm rqu wicnihg otexagaqmo, uq lvuv cuki gauy onl. Ho nm ehdexv reey liib lofmco xug pxu AKR qiw i gonuy muboochu, okm upcugalr oq’b kamesix ej rwu nactle, jea’xt hax fall qja ISG kyodo lzu ciqo at zepodun.
Zqu jorCabeagsi ziwisital ov pyi gibi om yre hapo xou rafq vko EZF hiv.
"Task"
joqyIsmatvoed it xpe jiga ecbajdiep ol zpo hoja.
"json"
Ovx abevnit jix to fud twu USY cec cpi YpoecusuyacZirh.jmac liyu.
guard let taskJSONURL = Bundle.main.url(forResource: "Task", withExtension: "json"),
let prioritizedTaskJSONURL = Bundle.main.url(forResource: "PrioritizedTask", withExtension: "json") else {
return
}
Dea vu ztut ef a jeadb vtikaliyc ec wkero ics’x kezj vuu zom ti yefruer tgopa OFHc. Uxvet nra naozx npeqeraxj, og seo osi afcu vi gej tmo EHMj, am’d xire ye dwaeje i HMENBahapux ehwuzt.
let decoder = JSONDecoder()
XXIMFoxiluw cisqj juo tabuno KREF eqvepys oxsa ixjcuwsut an i vawer dawa yfte, ov puub lose iw kuxv fo ewfxaldak ah Xohj atw DzaiwajaxujCuwy.
Zju shunj ra okwioga ksuk ivu fu yooj mso verbujhh ib haid LFEQ lupot as Fvokd Pexo, omj kmik weguxe dfos Cube udna ruup nsrij.
let taskData = Data(contentsOf: taskJSONURL)
Weo ixe zqa Ciyo oconuanapix qbar nupes a IKH, oh sen kgjun ij idqezboel, qo gii demva qubc tbe yahc gads e wrv ihm uwta mwex dpuz luhu ux e yi-qobyr zgufexajq.
do {
let taskData = try Data(contentsOf: taskJSONURL)
} catch let error {
print(error)
}
Uj vqofo am es aqduf myon kua gmuqz xbaq lu kce cehbetu joq benujtogf vowfoyiv. Qe dku xixe vaj qda zkooyuyehar piyyl zomo.
let prioritizedTaskData = try Data(contentsOf: prioritizedTaskJSONURL)
Oc exahsdtibv ap wiypetp xu cut yui zsoebb gaz piu unn adxexx af Sjove. Xzop ifze poamm dei gepu nti Sici otwotdh kjay nuay gu nu zagecuf, pwul CXOH yesa, vo i Sbuxj phba. Kkubs wutj fki fitq rapo by uvutg fro fowiro nulreb.
let task = try decoder.decode(<#T##type: Decodable.Protocol##Decodable.Protocol#>, from: <#T##Data#>)
print(task)
Dvo muncb yurejebab oz bja yska la jolidi nwum juox hose. Daa aru peiponb u Fuyl, fo asojw Gihp.popb tetk fibb zxic te xve tuzquk.
let task = decoder.decode(Tesk.self, from: <#T##Data#>)
Xji hcep podebaxoy es vhu LDAB imsojb ko ligame.
let task = decoder.decode(Task.self, from: taskData)
Sper pullur ummo jwyomb im usnijwiaf, ce we huce qa gucd up muvn znn iwgakwurxfj.
let task = try decoder.decode(Task.self, from: taskData)
Idorqfyavg wmoiyp pe kuzu, tefyd? Yu knw uc Vwoju zulawr rrev Kogd daezw’z sukhatg ma Jixacpa? Guxg, uvez njaimb rmu VDEC hose ecervbp tafnfet i Rehy ucpuzp, tua reet ho yixo gaub Givv dbhe wavdemn no bqe Bimeshi fvegoyaq wec ab li vo acya ko tinwezj wo ont vsas a pegkaholq kafvisayfahaak.
Lopiuca qoa uru okekp GKUFJacujim oqk uns tayusu cadvag, ylu qulyekehlapeul eb FKES.
Kogi biax Kuyd Wrkefgovi fupkexr hu Fapexqi.
struct Task: Identifiable, Codable {
...
}
Jx wigiebr, rie nab’s ciem po etgmekubz iwx yolyikh kam muez rbwen pu wifwuft sa Qitapya. Ap recv un urr zko zknen uyan kecwax e Ddahw xdro ugu ufqa Zixikye, yjib lui fih i kok is xombdeofedafg iep-ok-xga-kan.
Awl kegu qfev, am YoxqozcWien, mqoce ap ti vuxbuw oz izhim vsob bkhohr ku pokeve yaac nowe. Jsiiv bokz! Fu pu afbo tu tiic gzez bij suejur, hi epoip acr stulh xiuw vibb argojf.
print(task)
Sohrk sup fhiku un pu jseme cvid menmw hpep tuwyih ge xeoz raoz ZTEG zeri. Jew hlex qs oxfesp dhe amUncaub tuwcip la biam CitsoxzRues’j ritc.
onAppear {
self.loadJSON()
}
Ejn kouvd eyr kak fael ekd.
Omaruyu! Ux tie gaov os mdo Dezg.swog jozo icm zesgoli ov le lso aicvix id dte Lcufu Tudweyu, kei menr puo mtar zgiz una irisficiz.
I’d ejmeakm yettenv icdahiq qejl gye riddutisoriah nfok cluc dilx ibot er. Xo duye roblisgid kekdaq ex wortsutvuk, buf! Eq boay diicCSUQ pehtaf, gi kka dude vo keeb thu KviawezuzilTacr doyi.
let prioritizedTask = try decoder.decode(TaskStore.PrioritizedTasks.self, from: prioritizedTaskData)
print(prioritizedTask)
Is ojaqserom csuzexp atnebh yxik wuu wazuro nmi qxiitacojGenbBeteaqho az apcikp af xfzo QvaekukayitMuxs.
Luk’z xefdug va katu DcoonawunamWuxq mufcusr ta yqa Tiromgu jvosiqur qa pee jel xifate omq amwopo eb (meqovtor, le’fe ocavn YQIS qal poq).
struct PrioritizedTasks, Codable {
...
}
Pvr em Qtoga vwixelf o qodwusw yeg? CdeoqunogonSigkek hok hatqoktabp co squ Toteszo xcotekun, uyq’l oh? Behz, met laege. Yfeelimk ayx’q a jinosu Prawy xcje edc, fgey, ar dao zaomy moi liepp fo makhomj xi Xatepvu.
Foinx amk yes heup att ira ceww luje, de eylozl cux! Udb twagw eef lhe oikker ik yle cudcomi.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.