Json 来自现有 NSData 的结果为 null iOS

Json result null from existing NSData iOS

我实现了这个方法来从网络服务器json获取数据

-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{ 
    magazineJsonArray = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
}

它 returns null 值但是 data 不是一个空对象。 我尝试这样做:NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];它 returns 一个 NSString 分为 3 个部分,我不知道如何将我的数据放入 NSDictionary 这是我尝试获取字符串时在日志中得到的内容:

2015-03-23 17:35:15.638 AppTest[5604:70b] str is{"products":[{"id":74,"id_default_image":"351","manufacturer_name":"Bose","price":"449.990000","name":[{"id":"1","value":"BOSE enceinte soundlink mobile + casque AE2I"},{"id":"2","value":"Bose soundlink mobile + helmet AE2I"}]},{"id":76,"id_default_image":"5006","manufacturer_name":"Bose","price":"398.000000","name":[{"id":"1","value":"BOSE Enceintes 301 serie V X2"},{"id":"2","value":"Bose 301 series V X 2"}]},{"id":81,"id_default_image":"380","manufacturer_name":"Bose","price":"649.000000","name":[{"id":"1","value":"BOSE Enceintes freespace 51 (paire)"},{"id":"2","value":"Bose freespace 51 (pair)"}]},{"id":114,"id_default_image":"551","manufacturer_name":"Apple","price":"659.000000","name":[{"id":"1","value":"Iphone 5s 32 Go"},{"id":"2","value":"Apple iphone 5S 32GO OR"}]},{"id":121,"id_default_image":"562","manufacturer_name":"De'Longhi","price":"279.000000","name":[{"id":"1","value":"Machine à café Delonghi lattissima+ Nespresso argent givre EN520S"},{"id":"2","value":"Delonghi lattissima+ nespresso argent givre EN520S"}]},{"id":122,"id_default_image":"564","manufacturer_name":"Kitchen Chef","price":"350.000000","name":[{"id":"1","value":"Kitchen chef ZB06B : fabrique à glaçons, producteur d'eau chaude (90°C) et d'eau froide (moins de 10°C)"},{"id":"2","value":"Kitchen chef ZB06B"}]},{"id":336,"id_default_image":"4733","manufacturer_name":"La Maison de la Truffe","price":"44.000000","name":[{"id":"1","value":"Truffe Entière Extra Spécial 1 Truffe"},{"id":"2","value":"Truffe entiére extra spécial 1 truffe"}]},{"id":387,"id_default_image":"1110","manufacturer_name":"Dior ","price":"21000.000000","name":[{"id":"1","value":"La D de Dior"},{"id":"2","value":"La D de Dior"}]},{"id":389,"id_default_image":"4764","manufacturer_name":"A. Lange & Sohne","price":"20000.000000","name":[{"id":"1","value":"Montre 1815 Or gris"},{"id":"2","value":"1815"}]},{"id":394,"id_default_image":"4797","manufacturer_name":"Oris","price":"1550.000000","name":[{"id":"1","value":"Oris BC4 Retrograde Day"},{"id":"2","value":"Oris BC4 Retrograde Day"}]},{"id":397,"id_default_image":"4864","manufacturer_name":"Tag Heuer","price":"1600.000000","name":[{"id":"1","value":"FORMULA 1 Calibre S Chronographe"},{"id":"2","value":"FORMULA 1 Calibre S Chronographe"}]},{"id":400,"id_default_image":"4804","manufacturer_name":"Oris","price":"1600.000000","name":[{"id":"1","value":"Oris Divers Small Second, Date"},{"id":"2","value":"Oris Divers Small Second, Date"}]},{"id":401,"id_default_image":"4805","manufacturer_name":"Tag Heuer","price":"1600.000000","name":[{"id":"1","value":"FORMULA 1 Chronographe"},{"id":"2","value":"FORMULA 1 Chronographe"}]},{"id":406,"id_default_image":"4830","manufacturer_name":"Tag Heuer","price":"2050.000000","name":[{"id":"1","value":"Carrera Calibre 5"},{"id":"2","value":"Carrera Calibre 5"}]},{"id":413,"id_default_image":"4839","manufacturer_name":"Tag Heuer","price":"2100.000000","name":[{"id":"1","value":"Link Chronographe"},{"id":"2","value":"Link Chronographe"}]},{"id":416,"id_default_image":"4842","manufacturer_name":"Longines","price":"2120.000000","name":[{"id":"1","value":"The Longines Column-Wheel Sports Chronograph"},{"id":"2","value":"The Longines Column-Wheel Sports Chronograph"}]},{"id":417,"id_default_image":"4843","manufacturer_name":"Oris","price":"2130.000000","name":[{"id":"1","value":"Oris 2015-03-23 17:35:15.654 AppTest[5604:70b] str isWilliamsF1 Team Chronograph"},{"id":"2","value":"Oris WilliamsF1 Team Chronograph"}]},{"id":419,"id_default_image":"4815","manufacturer_name":"Hermès","price":"3100.000000","name":[{"id":"1","value":"Arceau"},{"id":"2","value":"Arceau"}]},{"id":430,"id_default_image":"4820","manufacturer_name":"Chaumet","price":"4600.000000","name":[{"id":"1","value":"Dandy Grande Date"},{"id":"2","value":"Dandy Grande Date"}]},{"id":431,"id_default_image":"4819","manufacturer_name":"Jeanrichard","price":"4600.000000","name":[{"id":"1","value":"1681 Ronde Seconde Centrale"},{"id":"2","value":"1681 round second central"}]},{"id":436,"id_default_image":"4867","manufacturer_name":"Mauboussin","price":"500.000000","name":[{"id":"1","value":"Amour, le Jour se Lève"},{"id":"2","value":"Love, the day to survey"}]},{"id":442,"id_default_image":"1167","manufacturer_name":"Leonor greyl","price":"51.000000","name":[{"id":"1","value":"Masque régénérant à l'huile rare de figue de Barbarie"},{"id":"2","value":"Masque régénérant à l'huile rare de figue de Barbarie"}]},{"id":456,"id_default_image":"4850","manufacturer_name":"Tudor","price":"1580.000000","name":[{"id":"1","value":"Clair de Rose"},{"id":"2","value":"Clair de Rose"}]},{"id":460,"id_default_image":"4853","manufacturer_name":"Hermès","price":"1750.000000","name":[{"id":"1","value":"Heure H Quartz"},{"id":"2","value":"Heure H Quartz"}]},{"id":462,"id_default_image":"1187","manufacturer_name":"Leonor greyl","price":"29.500000","name":[{"id":"1","value":"Eclat Naturel"},{"id":"2","value":"Eclat Naturel"}]},{"id":464,"id_default_image":"1188","manufacturer_name":"Leonor greyl","price":"29.500000","name":[{"id":"1","value":"Mousse au Lotus Volumatrice"},{"id":"2","value":"Mousse au Lotus Volumatrice"}]},{"id":466,"id_default_image":"4874","manufacturer_name":"Baume & Mercier","price":"2870.000000","name":[{"id":"1","value":"Linea"},{"id":"2","value":"Linea"}]},{"id":475,"id_default_image":"4876","manufacturer_name":"Dior ","price":"2800.000000","name":[{"id":"1","value":"La mini D de Dior"},{"id":"2","value":"Mini D de Dior"}]},{"id":476,"id_default_image":"4862","manufacturer_name":"Dior ","price":"2800.000000","name":[{"id":"1","value":"La Mini D de Dior"},{"id":"2","value":"The Mini D de Dior"}]},{"id":480,"id_default_image":"4878","manufacturer_name":"Raymond Weil","price":"2250.000000","name":[{"id":"1","value":"Noemia"},{"id":"2","value":"Noemia"}]},{"id":484,"id_default_image":"1209","manufacturer_name":"Leonor greyl","price":"22.000000","name":[{"id":"1","value":"Crème aux Fleurs"},{"id":"2","value":"Crème aux Fleurs"}]},{"id":489,"id_default_image":"1213","manufacturer_name":"Leonor greyl","price":"22.000000","name":[{"id":"1","value":"Laque Souple"},{"id":"2","value":"Flexible Hairspray"}]},{"id":498,"id_default_image":"4887","manufacturer_name":"Chanel","price":"3800.000000","name":[{"id":"1","value":"J12 Marine Céramique Blanche"},{"id":"2","value":"J12 Marine Céramique Blanche"}]},{"id":504,"id_default_image":"4893","manufacturer_name":"Rado","price":"6240.000000","name":[{"id":"1","value":"eSenza eSenza Blue Jubilé Cadran Bleu pavé de Saphirs"},{"id":"2","value":"eSenza eSenza Blue Jubilé Cadran Bleu pavé de Saphirs"}]},{"id":518,"id_default_image":"1242","manufacturer_name":"Dior ","price":"321.900000","name":[{"id":"1","value":"Dior Prestige Crème Souveraine"},{"id":"2","value":"Dior Prestige Crème Souveraine"}]},{"id":519,"id_default_image":"1243","manufacturer_name":"Dior ","price":"345.900000","name":[{"id":"1","value":"L'Or de Vie La Crème"},{"id":"2","value":"L'Or de Vie La Crème"}]},{"id":743,"id_default_image":"1680","manufacturer_name":"Lancôme","price":"76.900000","name":[{"id":"1","value":"Génifique Nutrics"},{"id":"2","value":"Génifique Nutrics"}]},{"id":750,"id_default_image":"1687","manufacturer_name":"Lancôme","price":"26.900000","name":[{"id":"1","value":"La Rose Baume Corps"},{"id":"2","value":"La Rose Baume Corps"}]},{"id":784,"id_default_image":"1721","manufacturer_name":"Chanel","price":"366.000000","name":[{"id":"1","value":"Sublimage L'Essence"},{"id":"2","value":"Sublimage L'Essence"}]},{"id":798,"id_default_image":"1737","manufacturer_name":"Guerlain","price":"292.500000","name":[{"id":"1","value":"Orchidée Impériale Crème Cou et Décolleté"},{"id":"2","value":"Orchidée Impériale Crème Cou et Décolleté"}]},{"id":816,"id_default_image":"1753","manufacturer_name":"Guerlain","price":"92.900000","name":[{"id":"1","value":"Super Aqua Sérum"},{"id":"2","value":"Super Aqua Sérum"}]},{"id":822,"id_default_image":"1760","manufacturer_name":"Guerlain","price":"77.000000","name":[{"id":"1","value":"Abeille Royale Huile Visage"},{"id":"2","value":"Abeille Royale Huile Visage"}]},{"id":830,"id_default_image":"1767","manufacturer_name":"Guerlain","price":"108.900000","name":[{"id":"1","value":"Shalimar Extrait de parfum "},{"id":"2","value":"Shalimar Extrait de parfum "}]},{"id":834,"id_default_image":"1771","manufacturer_name":"Saint Laurent","price":"93.900000","name":[{"id":"1","value":"Yvresse Eau de Toilette"},{"id":"2","value":"Yvresse Eau de Toilette"}]},{"id":835,"id_default_image":"1772","manufacturer_name":"Saint Laurent","price":"93.900000","name":[{"id":"1","value":"Nu Eau de Parfum"},{"id":"2","value":"Nu Eau de Parfum"}]},{"id":839,"id_default_image":"1776","manufacturer_name":"Saint Laurent","price":"95.900000","name":[{"id":"1","value":"Forever Youth Liberator Fluide FPS 15"},{"id":"2","value":"Forever Youth Liberator Fluide FPS 15"}]},{"id":866,"id_default_image":"1854","manufacturer_name":"Clarins","price":"24.900000","name":[{"id":"1","value":"Rouge Eclat"},{"id":"2","value":"Rouge Eclat"}]},{"id":883,"id_default_image":"1929","manufacturer_name":"Clarins","price":"116.500000","name":[{"id":"1","value":"Supra Sérum Haute Exigence"},{"id":"2","value":"Supra Sérum Haute Exigence"}]},{"id":885,"id_default_image":"1930","manufacturer_name":"Clarins","price":"104.500000","name":[{"id":"1","value":"Multi-Intensive Crème Haute Exigence Soir peaux très sèches"},{"id":"2","value":"Multi-Intensive Crème Haute Exigence Soir peaux très sèches"}]},{"id":887,"id_default_image":"1936","manufacturer_name":"Clarins","price":"104.500000","name":[{"id":"1","value":"Multi-Intensive Crème Haute Exigence Soir"},{"id":"2","value":"Multi-Intensive Crème Haute Exigence Soir"}]},{"id":895,"id_default_image":"1969","manufacturer_name":"Clarins","price":"97.500000","name":[{"id":"1","value":"Capital Lumière Nuit Peaux Sèches"},{"id":"2","value":"Capital Lumière Nuit Peaux Sèches"}]},{"id":896,"id_default_image":"1970","manufacturer_name":"Clarins","price":"97.500000","name":[{"id":"1","value":"Capital Lumière Nuit Soin anti-âge revitalisant"},{"id":"2","value":"Capital Lumière Nuit Soin anti-âge revitalisant"}]},{"id":898,"id_default_image":"1981","manufacturer_name":"Clarins","price":"92.500000","name":[{"id":"1","value":"Capital Lumière Jour Peaux Sèches"},{"id":"2","value":"Capital Lumière Jour Peaux Sèches"}]},{"id":900,"id_default_image":"1987","manufacturer_name":"Clarins","price":"92.500000","name":[{"id":"1","value":"Capital Lumière Jour SPF15 Soin anti-âge unifiant"},{"id":"2","value":"Capital Lumière Jour SPF15 Soin anti-âge unifiant"}]},{"id":911,"id_default_image":"2047","manufacturer_name":"Clarins","price":"54.500000","name":[{"id":"1","value":"Sérum Corps Peau Neuve"},{"id":"2","value":"Sérum Corps Peau Neuve"}]},{"id":913,"id_default_image":"2053","manufacturer_name":"Clarins","price":"52.000000","name":[{"id":"1","value":"Masvelt Crème Anti-Rondeurs Rebelles"},{"id":"2","value":"Masvelt Crème Anti-Rondeurs Rebelles"}]},{"id":961,"id_default_image":"2208","manufacturer_name":false,"price":"30.000000","name":[{"id":"1","value":"Beurre de Sel Exfoliant"},{"id":"2","value":"Butter scrub salt"}]},{"id":963,"id_default_image":"4966","manufacturer_name":false,"price":"1235.000000","name":[{"id":"1","value":"Bracelet Charms balle or"},{"id":"2","value":"Bracelet Charms ball gold"}]},{"id":973,"id_default_image":"4975","manufacturer_name":false,"price":"2260.000000","name":[{"id":"1","value":"Bague Puzzle Toi & Moi"},{"id":"2","value":"Ring Puzzle Toi & Moi"}]},{"id":989,"id_default_image":"2255","manufacturer_name":false,"price":"37.500000","name":[{"id":"1","value":"Hydratant Essentiel de Jour Peaux normales à sèches"},{"id":"2","value":"Most of day normal to dry skin moisturizer"}]},{"id":1003,"id_default_image":"2288","manufacturer_name":"ALEXANDER WANG","price":"755.000000","name":[{"id":"1","value":"Veste sans manches en crêpe à effet tablier dans le dos "},{"id":"2","value":"Jacket sleeveless crepe effect deck in the back"}]},{"id":1127,"id_default_image":"3081","manufacturer_name":"Beats by Dre","price":"399.950000","name":[{"id":"1","value":"Beatbox portable"},{"id":"2","value":"Beatbox portable"}]},{"id":1129,"id_default_image":"3096","manufacturer_name":"Beats by Dre","price":"399.950000","name":[{"id":"1","value":"Beatbox portable"},{"id":"2","value":"Beatbox portable"}]},{"id":1186,"id_default_image":"3269","manufacturer_name":"Carita","price":"52.000000","name":[{"id":"1","value":"Crème-en-lait demaquillante jeunesse"},{"id":"2","value":"Crème-en-lait demaquillante jeunesse"}]},{"id":1191,"id_default_image":"3275","manufacturer_name":"Carita","price":"65.500000","name":[{"id":"1","value":"Ideal Hydratation Sérum Des Lagons"},{"id":"2","value":"Ideal Hydratation Sérum Des Lagons"}]},{"id":1198,"id_default_image":"3282","manufacturer_name":"Carita","price":"36.000000","name":[{"id":"1","value":"Lotion Nacrée"},{"id":"2","value":"Lotion Nacrée"}]},{"id":1202,"id_default_image":"3286","manufacturer_name":"Carita","price":"36.000000","name":[{"id":"1","value":"Eau des Lagons"},{"id":"2","value":"Eau des Lagons"}]},{"id":1233,"id_default_image":"3327","manufacturer_name":"Caron","price":"220.000000","name":[{"id":"1","value":"Parfum \"N'aimez que moi\" "},{"id":"2","value":"Parfum \"N'aimez que moi\" "}]},{"id":1235,"id_default_image":"3330","manufacturer_name":"Caron","price":"220.000000","name":[{"id":"1","value":"Parfum \"Délire de roses\" "},{"id":"2","value":"Parfum \"Délire de roses\" "}]},{"id":1236,"id_default_image":"16704","manufacturer_name":"Caron","price":"52.000000","name":[{"id":"1","value":"Poudre libre rose "},{"id":"2","value":"Poudre libre rose "}]},{"id":1326,"id_default_image":"3604","manufacturer_name":"Bernardaud","price":"281.000000","name":[{"id":"1","value":"Coffret théière or + boite de thé"},{"id":"2","value":"Coffret théière or + boite de thé"}]},{"id":1327,"id_default_image":"3605","manufacturer_name":"Bernardaud","price":"281.000000","name":[{"id":"1","value":"Coffret théière platine + boite de thé"},{"id":"2","value":"Teapot box Platinum + box tea"}]},{"id":1328,"id_default_image":"3607","manufacturer_name":"Bernardaud","price":"243.000000","name":[{"id":"1","value":"Coffret 1 théière + 1 boite de thé"},{"id":"2","value":"Box 1 teapot + 1 box of tea"}]},{"id":1329,"id_default_image":"3608","manufacturer_name":"Bernardaud","price":"232.000000","name":[{"id":"1","value":"Théière or"},{"id":"2","value":"Teapot gold"}]},{"id":1330,"id_default_image":"3609","manufacturer_name":"Bernardaud","price":"232.000000","name":[{"id":"1","value":"Théière platine"},{"id":"2","value":"Platinum teapot"}]},{"id":1331,"id_default_image":"3610","manufacturer_name":"Bernardaud","price":"199.000000","name":[{"id":"1","value":"Théière verte"},{"id":"2","value":"Green teapot"}]},{"id":1556,"id_default_image":"4400","manufacturer_name":"Atelier Cologne","price":"121.500000","name":[{"id":"1","value":"Cologne Absolue Ambre Nue Eau de Parfum"},{"id":"2","value":"Cologne Absolue Ambre Nue Eau de Parfum"}]},{"id":1557,"id_default_image":"4401","manufacturer_name":"Atelier Cologne","price":"100.000000","name":[{"id":"1","value":"Cologne Absolue Vétiver Fatal Eau de Cologne"},{"id":"2","value":"Cologne Absolue Vétiver Fatal Eau de Cologne"}]},{"id":1558,"id_default_image":"4402","manufacturer_name":"Atelier Cologne","price":"110.500000","name":[{"id":"1","value":"Cologne Absolue Vanille Insensée Eau de Parfum"},{"id":"2","value":"Cologne Absolue Vanille Insensée Eau de Parfum"}]},{"id":1560,"id_default_image":"4404","manufacturer_name":"Atelier Cologne","price":"121.500000","name":[{"id":"1","value":"Cologne Absolue Rose Anonyme Eau de Cologne"},{"id":"2","value":"Cologne Absolue Rose Anonyme Eau de Cologne"}]},{"id":1561,"id_default_image":"4405","manufacturer_name":"Atelier Cologne","price":"99.500000","name":[{"id":"1","value":"Grand Néroli Cologne Absolue Eau de Parfum"},{"id":"2","value":"Grand Néroli Cologne Absolue Eau de Parfum"}]},{"id":1562,"id_default_image":"4406","manufacturer_name":"Atelier Cologne","price":"110.500000","name":[{"id":"1","value":"Trèfle Pur Cologne Absolue Eau de Parfum"},{"id":"2","value":"Trèfle Pur Cologne Absolue Eau de Parfum"}]},{"id":1563,"id_default_image":"4407","manufacturer_name":"Atelier Cologne","price":"165.900000","name":[{"id":"1","value":"Ecrin Absolu Gold Leather Eau de Parfum"},{"id":"2","value":"Ecrin Absolu Gold Leather Eau de Parfum"}]},{"id":1564,"id_default_image":"4408","manufacturer_name":"Atelier Cologne","price":"149.500000","name":[{"id":"1","value":"Cologne Absolue Silver Iris Eau de Parfum"},{"id":"2","value":"Cologne Absolue Silver Iris Eau de Parfum"}]},{"id":1566,"id_default_image":"4410","manufacturer_name":false,"price":"48.000000","name":[{"id":"1","value":"Tourmaline Charged Crème Hydratante"},{"id":"2","value":"Tourmaline Charged hydrating cream"}]},{"id":1575,"id_default_image":"4419","manufacturer_name":"Carolina Herrera","price":"66.900000","name":[{"id":"1","value":"212 VIP Eau de Parfum"},{"id":"2","value":"212 VIP Eau de Parfum"}]},{"id":1587,"id_default_image":"4431","manufacturer_name":"Chanel","price":"110.500000","name":[{"id":"1","value":"Le Lift Crème - 50g"},{"id":"2","value":"Le Lift Crème"}]},{"id":1595,"id_default_image":"4439","manufacturer_name":false,"price":"34.900000","name":[{"id":"1","value":"Crème Lavante au Citron"},{"id":"2","value":"Cleansing with lemon cream"}]},{"id":1600,"id_default_image":"4445","manufacturer_name":"Clinique","price":"55.000000","name":[{"id":"1","value":"Superdefense SPF20 Hydratant Défense Quotidienne"},{"id":"2","value":"Superdefense SPF20 Hydratant Défense Quotidienne"}]},{"id":1613,"id_default_image":"4463","manufacturer_name":"Saint Laurent","price":"53.300000","name":[{"id":"1","value":"Coffret eau de parfum Parisienne"},{"id":"2","value":"Coffret eau de parfum Parisienne"}]},{"id":1620,"id_default_image":"4474","manufacturer_name":"Saint Laurent","price":"85.900000","name":[{"id":"1","value":"Eau de parfum Cinéma"},{"id":"2","value":"Eau de perfume theater"}]},{"id":1627,"id_default_image":"4481","manufacturer_name":"Saint Laurent","price":"59.500000","name":[{"id":"1","value":"Crème forever light creator"},{"id":"2","value":"Cream forever light creator"}]},{"id":1631,"id_default_image":"4484","manufacturer_name":"Saint Laurent","price":"87.900000","name":[{"id":"1","value":"Sérum forever youth liberator"},{"id":"2","value":"Serum forever youth liberator"}]},{"id":1633,"id_default_image":"4486","manufacturer_name":"Saint Laurent","price":"95.900000","name":[{"id":"1","value":"Fluide FPS 15"},{"id":"2","value":"Fluide FPS 15"}]},{"id":1641,"id_default_image":"4494","manufacturer_name":"Saint Laurent","price":"72.000000","name":[{"id":"1","value":"Crème riche pour le corps"},{"id":"2","value":"Crème riche pour le corp"}]},{"id":1647,"id_default_image":"4500","manufacturer_name":"Viktor & Rolf","price":"145.000000","name":[{"id":"1","value":"Flowerbomb eau de toilette"},{"id":"2","value":"Flowerbomb eau de toilette"}]},{"id":1653,"id_default_image":"4506","manufacturer_name":"Dior ","price":"79.900000","name":[{"id":"1","value":"Capture Totale One Essential Régénérateur cel 2015-03-23 17:35:15.661 AppTest[5604:70b] str islulaire intense"},{"id":"2","value":"Capture total One Essential cellular regenerator intense"}]},{"id":1657,"id_default_image":"4510","manufacturer_name":"Van Cleef & Arpels","price":"76.500000","name":[{"id":"1","value":"Eau de parfum Féerie"},{"id":"2","value":"Eau de parfum Féerie"}]},{"id":1660,"id_default_image":"4513","manufacturer_name":"Van Cleef & Arpels","price":"73.500000","name":[{"id":"1","value":"Eau de toilette Gem"},{"id":"2","value":"Eau de toilette Gem"}]},{"id":1666,"id_default_image":"4519","manufacturer_name":"Dolce & Gabbana","price":"61.500000","name":[{"id":"1","value":"The One Eau de Parfum"},{"id":"2","value":"The One Eau de Parfum"}]},{"id":1668,"id_default_image":"4521","manufacturer_name":false,"price":"86.000000","name":[{"id":"1","value":"Eau de parfum Habanita"},{"id":"2","value":"Eau de perfume Habanita"}]},{"id":1669,"id_default_image":"4522","manufacturer_name":false,"price":"55.000000","name":[{"id":"1","value":"Xtend Your Youth Crème hydratante - 50g"},{"id":"2","value":"Xtend Your Youth cream moisturizing, smoothing and antioxidant"}]},{"id":1675,"id_default_image":"4527","manufacturer_name":false,"price":"65.000000","name":[{"id":"1","value":"Crème ultra-hydratante - 50g"},{"id":"2","value":"Lineless ® Infinite Moisture ® combination cream"}]},{"id":1691,"id_default_image":"17108","manufacturer_name":"Lanvin","price":"99.900000","name":[{"id":"1","value":"Eau de parfum Arpège"},{"id":"2","value":"Eau de parfum Arpège"}]},{"id":1698,"id_default_image":"4551","manufacturer_name":"Lancôme","price":"86.900000","name":[{"id":"1","value":"Eau de parfum Hypnôse"},{"id":"2","value":"Eau de parfum Hypnôse"}]},{"id":1705,"id_default_image":"4558","manufacturer_name":"Lancôme","price":"73.000000","name":[{"id":"1","value":"Eau de parfum Miracle so magic"},{"id":"2","value":"Eau de parfum Miracle so magic"}]},{"id":1707,"id_default_image":"4560","manufacturer_name":"Lancôme","price":"83.500000","name":[{"id":"1","value":"Coffret de prestige eau de parfum hypnôse"},{"id":"2","value":"Coffret de prestige eau de parfum hypnôse"}]},{"id":1709,"id_default_image":"4562","manufacturer_name":"Lancôme","price":"106.000000","name":[{"id":"1","value":"Visionnaire LR 2412 4 %"},{"id":"2","value":"Visionnaire LR 2412 4 %"}]},{"id":1710,"id_default_image":"4563","manufacturer_name":"Lancôme","price":"56.900000","name":[{"id":"1","value":"Crème de jour Hydra zen (Peaux normales à mixtes)"},{"id":"2","value":"Crème de jour Hydra zen"}]},{"id":1711,"id_default_image":"4564","manufacturer_name":"Lancôme","price":"105.900000","name":[{"id":"1","value":"Advanced génifique"},{"id":"2","value":"Advanced génifique"}]},{"id":1712,"id_default_image":"4565","manufacturer_name":"Lancôme","price":"76.900000","name":[{"id":"1","value":"Génifique crème"},{"id":"2","value":"Génifique crème"}]},{"id":1714,"id_default_image":"4567","manufacturer_name":"Lancôme","price":"62.000000","name":[{"id":"1","value":"Crème de nuit Hydrazen"},{"id":"2","value":"Crème de nuit Hydrazen"}]},{"id":1718,"id_default_image":"4571","manufacturer_name":"Lancôme","price":"106.900000","name":[{"id":"1","value":"Rénergie multi-lift reviva plasma"},{"id":"2","value":"Rénergie multi-lift reviva plasma"}]},{"id":1729,"id_default_image":"4582","manufacturer_name":"Elie Saab","price":"50.500000","name":[{"id":"1","value":"ELIE SAAB Le Parfum Eau de Parfum"},{"id":"2","value":"ELIE SAAB Le Parfum Eau de Parfum"}]},{"id":1731,"id_default_image":"4584","manufacturer_name":"Estée Lauder","price":"50.500000","name":[{"id":"1","value":"Modern Muse Eau de parfum"},{"id":"2","value":"Modern Muse Eau de perfume"}]},{"id":1734,"id_default_image":"4590","manufacturer_name":"Akris","price":"2370.000000","name":[{"id":"1","value":"Veste imprimée"},{"id":"2","value":"Printed jacket"}]},{"id":1738,"id_default_image":"4599","manufacturer_name":"Akris","price":"960.000000","name":[{"id":"1","value":"Tunique imprimée en coton"},{"id":"2","value":"Printed cotton tunic"}]},{"id":1762,"id_default_image":"4646","manufacturer_name":"Givenchy","price":"58.900000","name":[{"id":"1","value":"Play For Her Eau de Toilette"},{"id":"2","value":"Play For Her Eau de Toilette"}]},{"id":1772,"id_default_image":"4656","manufacturer_name":"Guerlain","price":"55.500000","name":[{"id":"1","value":"Shalimar Eau de Parfum\t"},{"id":"2","value":"Shalimar Eau de Parfum\t"}]},{"id":1787,"id_default_image":"4670","manufacturer_name":"Hermès","price":"60.500000","name":[{"id":"1","value":"Jour d'Hermès Absolu Eau de Parfum\t "},{"id":"2","value":"Jour d'Hermès Absolu Eau de Parfum\t "}]},{"id":1788,"id_default_image":"4671","manufacturer_name":"Hermès","price":"87.900000","name":[{"id":"1","value":"Terre d'Hermès Eau Très Fraîche Eau de Toilette"},{"id":"2","value":"Terre d'Hermès Eau Très Fraîche Eau de Toilette"}]},{"id":1789,"id_default_image":"4672","manufacturer_name":"Hermès","price":"72.500000","name":[{"id":"1","value":"Voyage d'Hermès Parfum"},{"id":"2","value":"Voyage d'Hermès Parfum"}]},{"id":1790,"id_default_image":"4673","manufacturer_name":"Hermès","price":"85.000000","name":[{"id":"1","value":"Eau de Mandarine Ambrée Eau de Cologne"},{"id":"2","value":"Water of Mandarine amber Eau de Cologne"}]},{"id":1791,"id_default_image":"4675","manufacturer_name":"Hermès","price":"61.500000","name":[{"id":"1","value":"Terre d'Hermès Eau de Toilette"},{"id":"2","value":"Terre d'Hermès Eau de Toilette"}]},{"id":1792,"id_default_image":"4676","manufacturer_name":"Hermès","price":"78.500000","name":[{"id":"1","value":"Eau des Merveilles Eau de Toilette"},{"id":"2","value":"The wonders Eau de Toilette water"}]},{"id":1793,"id_default_image":"4677","manufacturer_name":"Hermès","price":"65.900000","name":[{"id":"1","value":"Un Jardin sur le Nil Eau de Toilette"},{"id":"2","value":"A garden on the Nile Eau de Toilette"}]},{"id":1794,"id_default_image":"4678","manufacturer_name":"Hermès","price":"50.900000","name":[{"id":"1","value":"Eau d'Orange Verte Eau de Cologne"},{"id":"2","value":"Orange green water of Cologne"}]},{"id":1795,"id_default_image":"4679","manufacturer_name":"Hermès","price":"89.900000","name":[{"id":"1","value":"Calèche Soie de Parfum"},{"id":"2","value":"Caleche perfume silk"}]},{"id":1799,"id_default_image":"4684","manufacturer_name":"Jimmy Choo","price":"64.500000","name":[{"id":"1","value":"Flash Coffret Eau de Parfum"},{"id":"2","value":"Flash box Eau de Parfum"}]},{"id":1801,"id_default_image":"4686","manufacturer_name":"Jimmy Choo","price":"64.500000","name":[{"id":"1","value":"Jimmy Choo Flash Coffret Eau de Parfum"},{"id":"2","value":"Jimmy Choo Flash box Eau de Parfum"}]},{"id":1806,"id_default_image":"4691","manufacturer_name":"La Prairie","price":"271.000000","name":[{"id":"1","value":"Ice crystal Huile Sèche Cellulaire Suisse"},{"id":"2","value":"Ice crystal Huile Sèche Cellulaire Suisse"}]},{"id":1808,"id_default_image":"4693","manufacturer_name":"La Prairie","price":"369.900000","name":[{"id":"1","value":"Crème Caviar Luxe Visage"},{"id":"2","value":"Crème Caviar Luxe Visage"}]},{"id":1815,"id_default_image":"4700","manufacturer_name":"La Prairie","price":"183.500000","name":[{"id":"1","value":"Crème de Jour Anti-Age SPF 30"},{"id":"2","value":"Crème de Jour Anti-Age SPF 30"}]},{"id":1856,"id_default_image":"4931","manufacturer_name":"Christofle","price":"250.000000","name":[{"id":"1","value":"Sel et poivre"},{"id":"2","value":"Sel et poivre"}]},{"id":1903,"id_default_image":"5079","manufacturer_name":"Ermenegildo Zegna","price":"150.000000","name":[{"id":"1","value":"Echarpe drapeau"},{"id":"2","value":"Flag scarf"}]},{"id":1904,"id_default_image":"5078","manufacturer_name":"Ermenegildo Zegna","price":"255.000000","name":[{"id":"1","value":"Echarpe jacquard à chevre"},{"id":"2","value":"Scarf pattern to goat"}]},{"id":2049,"id_default_image":"5440","manufacturer_name":"Qlocktwo","price":"449.000000","name":[{"id":"1","value":"Qlocktwo touch "},{"id":"2","value":"Qlocktwo touch "}]},{"id":2050,"id_default_image":"5445","manufacturer_name":"Qlocktwo","price":"449.000000","name":[{"id":"1","value":"Qlocktwo touch "},{"id":"2","value":"Qlocktwo touch "}]},

你初始化 magazineJsonArray 对象了吗?

NSDictionary* magazineJsonArray= [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];

我强烈推荐访问以下文章。

https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Conceptual/Collections/Articles/Dictionaries.html

这是一个例子: Parsing a JSON array with dictionaries

您的对象是 Dictionary,因此您应该为其创建一个 NSDictionary 对象并相应地处理数据。

将来,如果您不知道收到的数据类型,您可以像这样对数据进行类型检查:

+ (id)deserializeJSONfromURL:(NSURL *)url {

    NSError *error = nil;

    NSData *jsonData = [self downloadDataFromURL:url];

    id jsonObject;

    if (jsonData) {
        jsonObject = [NSJSONSerialization JSONObjectWithData:jsonData
                                                        options:NSJSONReadingAllowFragments
                                                          error:&error];
        if (jsonObject && !error) {
            NSLog(@"Success!");
        }
        else if (error) {
            NSLog(@"Failed! Error: %@", [error localizedDescription]);
        }
    }

    return jsonObject;
}

+ (BOOL)isJSONFromURL:(NSString *)urlAsString typeOfClass:(Class)classType {

    id classObject =[classType new];

    NSURL *dataURL = [NSURL URLWithString:urlAsString];

    id jsonObject = [self deserializeJSONfromURL:dataURL];

    if ([jsonObject isKindOfClass:[classType class]]) {
        NSLog(@"The JSON data is %@ class compliant.", [classType description]);
        return YES;
    }

    NSLog(@"The JSON data is not %@ class compliant.", [classType description]);
    classObject = nil;
    jsonObject = nil;

    return NO;
}

并像这样使用它:

if ([MyDeserializerClass isJSONFromURL:@"anURL" typeOfClass:[NSDictionary class]]) {
      //is an NSDictionary compliant. Do something with it.
}

为了快速检查,您可以尝试这样的 NSLog 语句:

NSLog(@"Type of JSON data %@", [[jsonObject class] description]);

数据看起来都很合理,至少开始是这样。

第一步是检查您应该收到的 NSError,您在其中传递了 nil 作为错误参数。那会告诉你哪里出了问题。

有时服务器会发送 JSON 不属于那里的数据。例如,开头或结尾的额外零字节或文本中间的字节顺序标记。如果是这种情况,您需要仔细检查您的数据。例如,检查 NSData 是否包含任何零字节。