如何从JSON iOS swift解析字符周围的未终止字符串或字符周围的无效字符串?

时间:2019-06-29 08:40:18

标签: ios json swift xml

我正在执行XML解析,并在找到的字符委托方法上获取了字符串值,并进行了JSON序列化以获取数据。现在对于某些搜索值字符串已解析良好,并且我正在获取JSON数据,但是对于某些搜索字符串,我遇到了诸如字符周围的未终止字符串或字符周围的无效字符串之类的错误。请帮我解决这个问题。预先感谢。

控制台错误:

Started parsing...
[{"StateName":"SELANGOR","StateCode":"B","BusinessType":[],"BranchType":"Pejabat POS","BranchName":"Pejabat POS Mutiara Damansara","BranchCode":"1064","BranchAddress1":"Lot M2, Mezzanine Floor, Tesco Mutiara Damansara","BranchAddress2":"8, Jalan PJU 7/4, Mutiara Damansara, Petaling Jaya, ","BranchAddress3":"","Postcode":"47800","City":"Petaling Jaya","Latitude":"3.159858","Longitude":"101.613225","BranchContactNo":"03-77282016","BranchManagerName":"Zainal Jamian","OperationHours":"Isnin - Jumaat10.00pg - 6.00ptgSabtu10.00pg - 6.00ptgSabtu Minggu Pertama11.00pg - 3.00ptg"},{"StateName":"WP KUALA LUMPUR","StateCode":"WPKL","BusinessType":[],"BranchType":"Pejabat POS","BranchName":"Pejabat POS Mon't Kiara","BranchCode":"5050","BranchAddress1":"E-01-7A, Block E, Plaza Mon't Kiara,","BranchAddress2":"No. 2, Jalan Kiara,","BranchAddress3":"","Postcode":"50480","City":"Kuala Lumpur","Latitude":"3.165294338166839","Longitude":"101.6508936882019","BranchContactNo":"03-62015385","BranchManagerName":"Fazini bt Salleh","OperationHours":"Isnin - Jumaat8.30pg - 5.30ptgSabtu8.30pg - 1.00ptg"},{"StateName":"SELANGOR","StateCode":"B","BusinessType":[],"BranchType":"Pejabat POS","BranchName":"Pejabat POS Jalan Semangat","BranchCode":"1012","BranchAddress1":"No.18B,","BranchAddress2":"Seksyen 14/14,","BranchAddress3":"","Postcode":"46100","City":"Petaling Jaya","Latitude":"3.110186","Longitude":"101.636343","BranchContactNo":"03-79562268","BranchManagerName":"Rahimah Bt. Muhamad","OperationHours":"Isnin - Jumaat8.30pg - 5.30ptgSabtu8.30pg - 1.00ptg"},{"StateName":"SELANGOR","StateCode":"B","BusinessType":[],"BranchType":"Pejabat POS","BranchName":"Pejabat POS Seksyen 20 Petaling Jaya","BranchCode":"1036","BranchAddress1":"Jalan 20/16A,","BranchAddress2":"Taman Paramount,","BranchAddress3":"","Postcode":"46300","City":"Petaling Jaya","Latitude":"3.107497","Longitude":"101.624303","BranchContactNo":"03-78761494","BranchManagerName":"Zura Syafinash Mohd Amin","OperationHours":"Isnin - Jumaat8.30pg - 5.30ptgSabtu8.30pg - 1.00ptg"},{"StateName":"SELANGOR","StateCode":"B","BusinessType":[],"BranchType":"POS Mini","BranchName":"POS Mini Kampung Chempaka","BranchCode":"PM05985","BranchAddress1":"NO.143 JALAN PJU 1/1","BranchAddress2":"Kampung CHEMPAKA,","BranchAddress3":"","Postcode":"47301","City":"Petaling Jaya","Latitude":"3.116967","Longitude":"101.598338","BranchContactNo":"03-78031646","BranchManagerName":"MOHD NOH LOH BIN ABDULLAH","OperationHours":"Isnin  - Jumaat8.30pg - 4.30ptg"},{"StateName":"SELANGOR","StateCode":"B","BusinessType":[],"BranchType":"Pejabat POS","BranchName":"Pejabat POS Seksyen 17 Petaling Jaya","BranchCode":"4640","BranchAddress1":"100-P2.003, The School Blok J Jaya One, No. 72A,","BranchAddress2":"Jalan Universiti, Section 13,","BranchAddress3":"","Postcode":"46200","City":"Petaling Jaya","Latitude":"3.117604","Longitude":"101.634804","BranchContactNo":"03-79574143","BranchManagerName":"Muhamud Fozi Mehat","OperationHours":"Isnin - Jumaat9.30pg - 6.00ptgSabtu9.30pg - 6.00ptg"},{"StateName":"WP KUALA LUMPUR","StateCode":"WPKL","BusinessType":[],"BranchType":"Pejabat POS","BranchName":"Pejabat POS Taman Tun Dr. Ismail","BranchCode":"6000","BranchAddress1":"Lot 29395
Error Error Domain=NSCocoaErrorDomain Code=3840 "Unterminated string around character 3216." UserInfo={NSDebugDescription=Unterminated string around character 3216.}
&
Error Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.}
29396, Bangunan Petronas,","BranchAddress2":"Jalan Persiaran Zaaba, Taman Tun Dr. Ismail,","BranchAddress3":"","Postcode":"60000","City":"Kuala Lumpur","Latitude":"3.1421525","Longitude":"101.62518069999999","BranchContactNo":"03-77264026","BranchManagerName":"Zulkafle Harun","OperationHours":"Isnin - Jumaat8.30pg - 5.30ptgSabtu8.30pg - 1.00ptg"},{"StateName":"SELANGOR","StateCode":"B","BusinessType":[],"BranchType":"Pejabat POS","BranchName":"Pejabat POS Damansara Jaya","BranchCode":"1050","BranchAddress1":"35, Jalan SS 22/19,","BranchAddress2":"Damansara Jaya,","BranchAddress3":"","Postcode":"47400","City":"Petaling Jaya","Latitude":"3.127831","Longitude":"101.615982","BranchContactNo":"03-77285491","BranchManagerName":"NORMAZNIDAH BINTI MOHD","OperationHours":"Isnin - Jumaat8.30pg - 5.30ptgSabtu8.30pg - 1.00ptg"},{"StateName":"WP KUALA LUMPUR","StateCode":"WPKL","BusinessType":[],"BranchType":"POS Laju EziBox","BranchName":"POS Laju EziBox @Shell Sri Hartamas","BranchCode":"5053","BranchAddress1":"Off Jalan Bukit Kiara, ","BranchAddress2":"Kuala Lumpur, ","BranchAddress3":"Wilayah Persekutuan Kuala Lumpur","Postcode":"50480","City":"Kuala Lumpur","Latitude":"3.164073","Longitude":"101.651732","BranchContactNo":"03-22632626","BranchManagerName":"Mohd Tarmizi Bin Ismail","OperationHours":"Operating 24/7 Hours"},{"StateName":"WP KUALA LUMPUR","StateCode":"WPKL","BusinessType":[],"BranchType":"POS Laju EziBox","BranchName":"POS Laju EziBox @PO Universiti Malaya","BranchCode":"5911","BranchAddress1":"PO Universiti Malaya, Dewan Perdana Siswa Jalan Lembah Pantai, ","BranchAddress2":"Kuala Lumpur,","BranchAddress3":"Wilayah Persekutuan Kuala Lumpur.","Postcode":"59100","City":"Kuala Lumpur","Latitude":"3.149705","Longitude":"101.656163","BranchContactNo":"03-22632626","BranchManagerName":"Mohd Tarmizi Bin Ismail","OperationHours":"Operating 24/7 Hours"},{"StateName":"SELANGOR","StateCode":"B","BusinessType":[],"BranchType":"POS Laju EziBox","BranchName":"POS Laju EziBox @Tesco Extra Mutiara Damansara","BranchCode":"4783","BranchAddress1":"8, Jalan PJU 7/4, ","BranchAddress2":"Mutiara Damansara, Petaling Jaya, ","BranchAddress3":"Selangor Darul Ehsan","Postcode":"47800","City":"Petaling Jaya","Latitude":"3.159717","Longitude":"101.613137","BranchContactNo":"03-61402391","BranchManagerName":"Ahmad Saufi B Taib","OperationHours":"Operating 24/7 Hours"},{"StateName":"SELANGOR","StateCode":"B","BusinessType":[],"BranchType":"POS Laju EziDrop","BranchName":"POS Laju EziDrop @PO Giant Kota Damansara","BranchCode":"4788","BranchAddress1":"Pejabat Pos Giant Kota Damansara, F20
Error Error Domain=NSCocoaErrorDomain Code=3840 "Garbage at end." UserInfo={NSDebugDescription=Garbage at end.}
&
Error Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.}
21, ","BranchAddress2":"Tingkat 1, Giant Hypermarket Kota Damansara, ","BranchAddress3":"Petaling Jaya, Selangor Darul Ehsan","Postcode":"47840","City":"Petaling Jaya","Latitude":"3.156251","Longitude":"101.5944372","BranchContactNo":"03-61402391","BranchManagerName":"Ahmad Saufi B Taib","OperationHours":"Operating 24/7 HoursNext Working Day Delivery Cut Off Time : 4.00pm Monday - Saturday"},{"StateName":"SELANGOR","StateCode":"B","BusinessType":[],"BranchType":"POS Laju EziDrop","BranchName":"POS Laju EziDrop @PO Petaling Jaya","BranchCode":"4631","BranchAddress1":"Pejabat Pos Petaling Jaya, Seksyen 20, ","BranchAddress2":"Jalan 20/16A, Taman Paramount, ","BranchAddress3":"Petaling Jaya, Selangor Darul Ehsan.","Postcode":"46300","City":"Petaling Jaya","Latitude":"3.107519","Longitude":"101.6220818","BranchContactNo":"03-79603206","BranchManagerName":"Ahmad Shah Redza bin Mohd Radzuan","OperationHours":"Operating 24/7 HoursNext Working Day Delivery Cut Off Time : 4.00pm Monday - Saturday"},{"StateName":"SELANGOR","StateCode":"B","BusinessType":[],"BranchType":"POS Laju EziDrop","BranchName":"POS Laju EziDrop @PO Damansara Jaya","BranchCode":"4341","BranchAddress1":"Pejabat Pos Damansara Jaya, ","BranchAddress2":"35, Jalan SS 22/19, Damansara Jaya, ","BranchAddress3":"Petaling Jaya, Selangor Darul Ehsan.","Postcode":"47400","City":"Petaling Jaya","Latitude":"3.127863","Longitude":"101.615982","BranchContactNo":"03-61402391","BranchManagerName":"Ahmad Saufi B Taib","OperationHours":"Operating 24/7 HoursNext Working Day Delivery Cut Off Time : 4.00pm Monday - Saturday"},{"StateName":"SELANGOR","StateCode":"B","BusinessType":[],"BranchType":"POS Laju EziDrop","BranchName":"POS Laju EziDrop @PO Jalan Semangat","BranchCode":"4613","BranchAddress1":"Pejabat Pos Jalan Semangat, ","BranchAddress2":"No.18B, Jalan 14/14, Seksyen 14,","BranchAddress3":"Petaling Jaya, Selangor Darul Ehsan.","Postcode":"46100","City":"Petaling Jaya","Latitude":"3.1101859","Longitude":"101.6341543","BranchContactNo":"03-79603206","BranchManagerName":"Ahmad Shah Redza bin Mohd Radzuan","OperationHours":"Operating 24/7 HoursNext Working Day Delivery Cut Off Time : 4.00pm Monday - Saturday"},{"StateName":"SELANGOR","StateCode":"B","BusinessType":[],"BranchType":"POS Laju Kiosk","BranchName":"POS Laju Kiosk @LRT Kelana Jaya","BranchCode":"4735","BranchAddress1":"K2, Ground Floor, Stesen LRT Kelana Jaya,","BranchAddress2":"Lot. PT 8960 Seksyen SS4, Jalan Lebuhraya Petaling Jaya","BranchAddress3":"Petaling Jaya, Selangor Darul Ehsan.","Postcode":"47301","City":"Petaling Jaya","Latitude":"3.1159087","Longitude":"101.6001339","BranchContactNo":"03-79602806","BranchManagerName":"Ahmad Shah Redza bin Mohd Radzuan","OperationHours":"Kaunter PengeposanIsnin-Sabtu                         : 8.00 pg - 8.00 mlmSabtu Minggu Pertama      : 10.00 pg - 3.00 ptg
Error Error Domain=NSCocoaErrorDomain Code=3840 "Garbage at end." UserInfo={NSDebugDescription=Garbage at end.}
&
Error Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.}
Ahad"},{"StateName":"SELANGOR","StateCode":"B","BusinessType":[],"BranchType":"POS Laju Kiosk","BranchName":"POS Laju Kiosk @Encorp Strand Mall","BranchCode":"4779","BranchAddress1":"B-08, Jalan PJU 5/22, Encorp Strand Pusat Perdagangan,","BranchAddress2":"Kota Damansara PJU 5,","BranchAddress3":"Petaling Jaya, Selangor Darul Ehsan.","Postcode":"47810","City":"Petaling Jaya","Latitude":"3.1554957","Longitude":"101.5914995","BranchContactNo":"03-61402391","BranchManagerName":"Ahmad Saufi B Taib","OperationHours":"Kaunter PengeposanIsnin-Ahad : 10.00 pg - 8.00 mlm"},{"StateName":"SELANGOR","StateCode":"B","BusinessType":[],"BranchType":"POS Laju EziBox","BranchName":"POS Laju EziBox @Shell Damansara Jaya","BranchCode":"4742","BranchAddress1":"Jalan SS 24/1, Taman Sea, ","BranchAddress2":"Petaling Jaya, ","BranchAddress3":"Selangor Darul Ehsan.","Postcode":"47400","City":"Petaling Jaya","Latitude":"3.124047","Longitude":"101.613776","BranchContactNo":"03-61402391","BranchManagerName":"Ahmad Saufi B Taib","OperationHours":"Operating 24/7 Hours"},{"StateName":"SELANGOR","StateCode":"B","BusinessType":[],"BranchType":"POS Laju EziDrop","BranchName":"POS Laju EziDrop @PO One Utama","BranchCode":"4790","BranchAddress1":"Lot B21, One Utama Shopping Centre, 1, Persiaran Bandar Utama,","BranchAddress2":"Petaling Jaya,","BranchAddress3":"Selangor Darul Ehsan.","Postcode":"47800","City":"Petaling Jaya","Latitude":"3.151157","Longitude":"101.614634","BranchContactNo":"03-61402391","BranchManagerName":"Ahmad Saufi B Taib","OperationHours":"Operating 24/7 HoursNext Working Day Delivery Cut Off Time : 4.00pm Monday - Saturday"},{"StateName":"SELANGOR","StateCode":"B","BusinessType":[],"BranchType":"POS Laju EziDrop","BranchName":"POS Laju EziDrop @PO Tesco Mutiara Damansara","BranchCode":"4791","BranchAddress1":"Lot M2, Mezzanine Floor, Tesco Mutiara Damansara, No. 8, Jalan PJU 7/4, ","BranchAddress2":"Mutiara Damansara, Petaling Jaya,","BranchAddress3":"Selangor Darul Ehsan.","Postcode":"47800","City":"Petaling Jaya","Latitude":"3.160082","Longitude":"101.613286","BranchContactNo":"03-61402391","BranchManagerName":"Ahmad Saufi B Taib","OperationHours":"Operating 24/7 HoursNext Working Day Delivery Cut Off Time : 4.00pm Monday - Saturday"},{"StateName":"WP KUALA LUMPUR","StateCode":"WPKL","BusinessType":[],"BranchType":"Pejabat POS","BranchName":"Pejabat Pos Glo Damansara","BranchCode":"05019","BranchAddress1":"No 3A.03C, Level 3A, Menara Glomac Glomac Damansara, ","BranchAddress2":"Jalan Damansara ","BranchAddress3":" Kuala Lumpur","Postcode":"60000","City":"Kuala Lumpur","Latitude":"3.133852","Longitude":"101.629898","BranchContactNo":"0377314215","BranchManagerName":"Hasnulizam Bin Hassan","OperationHours":"Waktu OperasiIsnin - Ahad10.00 Pagi - 6.00 Ptg"},{"StateName":"SELANGOR","StateCode":"B","BusinessType":[],"BranchType":"Pejabat POS","BranchName":"Pos Malaysia The Starling Mall","BranchCode":"05113","BranchAddress1":" Lot G-001, Ground Floor, Pusat Perniagaan Starling Mall @ Uptown,  ","BranchAddress2":"No 6, Jalan SS21/37 Damansara Utama  ","BranchAddress3":"Petaling Jaya, Selangor","Postcode":"47400","City":"Petaling Jaya","Latitude":"3.1352","Longitude":"101.6227","BranchContactNo":"03-77315148","BranchManagerName":"Khairulnizam Abu Kassim","OperationHours":"Waktu OperasiIsnin - Ahad10.00 pagi- 6.00petang( PEJABAT LAMA SS2 PJ)"},{"StateName":"SELANGOR","StateCode":"B","BusinessType":[],"BranchType":"Pejabat POS","BranchName":"Pejabat POS Giant Kota Damansara","BranchCode":"10541105","BranchAddress1":"F 20
Error Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.}
&
Error Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.}
21, Tingkat 1,","BranchAddress2":"Giant Hypermarket Kota Damansara,","BranchAddress3":"","Postcode":"47840","City":"Petaling Jaya","Latitude":"3.156251","Longitude":"101.596626","BranchContactNo":"03-61422108","BranchManagerName":"Hasliza Ainun Shaari","OperationHours":"Isnin - Ahad10.00pg - 6.00ptg"},{"StateName":"SELANGOR","StateCode":"B","BusinessType":[],"BranchType":"Pejabat POS","BranchName":"Pejabat POS One Utama Shopping Centre","BranchCode":"1100'","BranchAddress1":"Lot B21,","BranchAddress2":"One Utama Shopping Centre, 1, Persiaran Bandar Utama,","BranchAddress3":"","Postcode":"47800","City":"Petaling Jaya","Latitude":"3.150825","Longitude":"101.614681","BranchContactNo":"03-77279746","BranchManagerName":"NURATIQAH BTE MOHAMED AMIN","OperationHours":"Isnin - Jumaat10.00pg - 6.00ptgSabtu10.00pg - 6.00ptg"},{"StateName":"SELANGOR","StateCode":"B","BusinessType":[],"BranchType":"Pejabat POS","BranchName":"Pejabat POS SEA Park SS2 Petaling Jaya","BranchCode":"1067","BranchAddress1":"No.26,","BranchAddress2":"Jalan SS 3/59E,","BranchAddress3":"","Postcode":"47300","City":"Petaling Jaya","Latitude":"3.110294","Longitude":"101.611860","BranchContactNo":"03-78745866","BranchManagerName":"Khairulnizam Abu Kassim","OperationHours":"Isnin - Jumaat8.30pg - 5.30ptgSabtu8.30pg - 1.00ptg"}]
Error Error Domain=NSCocoaErrorDomain Code=3840 "Garbage at end." UserInfo={NSDebugDescription=Garbage at end.}
Ended parsing...

0 个答案:

没有答案