Codableに関する最新の質問

0
答える

構造体はコード化可能です、それはそのすべてのプロパティがコード化可能であることを意味しますか?

私が理解しているように、構造体がコード化可能である場合、構造体のすべてのプロパティはコード化可能です。 タイプPKDrawing(PencilKitの構造体)のオブジェクトをエンコードしようとしましたが、タイプはコード化可能であるため、問題はありません。

codable swift

1
答える

Youtube Apiの人気のある動画からデータをデコードしようとすると、「Array <Any>をデコードする予定ですが、代わりに辞書が見つかりました」

Swiftは初めてで、ApiからSwiftアプリへのデータの解析を学んでいます。 人気動画のYoutubeAPiからデータを取得しようとしました:(https://developers.google.com/youtube/v3/docs/videos/list)データを取得できません。どこが間違っているのかわかりません。しかし、「配列をデコードすることを期待していましたが、代わりに辞書を見つけました。」

codable ios swift json

1
答える

次のAPIデータのコード化可能な構造を作成する方法

{ "status": true, "error": false, "data": [ { "type": 0, "title":"", "description":"", "data": [ { "images":"/media/banner/Glocart%20Shop/Glocart-Shop_moVB3tP.jpg", "is_external": true, "link":"https://www.wikipedia.org/", "product_id": null, "offer_list_id": null, "product_list_id": null }, { "images":"/media/banner/Grocery/Grocery_m341Az6.jpg", "is_external": false, "link": null, "product_id": null, "offer_list_id": 1, "product_list_id": null } ] }, { "type": 1, "title":"Categories", "description":"", "data": [ { "category_name":"Beverages", "category_id": 5, "category_icon":"/media/category_icon_upload_location/61ho157I07L._SX522__WpWCZ7h.jpg" }, { "category_name":"Tea & Coffee", "category_id": 6, "category_icon":"/media/category_icon_upload_location/Lipton-Green-Tea-Bags-250-SDL859816919-1-31762.jpg" }, { "category_name":"Body Care", "category_id": 3, "category_icon":"/media/category_icon_upload_location/nourishing-body-lotion-100ml_1024x1024.png" }, { "category_name":"Personal Hygiene", "category_id": 7, "category_icon":"/media/category_icon_upload_location/lif0259_2_1.jpg" }, { "category_name":"Jams & Preserves", "category_id": 32, "category_icon":"/media/category_icon_upload_location/kissan-mixed-fruit-jam-500-gm-164390973-ymzpr.jpg" }, { "category_name":"Air Fresheners", "category_id": 28, "category_icon":"/media/category_icon_upload_location/Godrej_Aer_Home_Air_Freshener_Spray_Morning_Misty_Meadows__fkCoOzL.jpg" }, { "category_name":"Chocolate", "category_id": 35, "category_icon":"/media/category_icon_upload_location/71p5hUVC0eL._SX569_.jpg" }, { "category_name":"Cosmetics & Makeup", "category_id": 27, "category_icon":"/media/category_icon_upload_location/81oA3GcTyRL._SL1500_.jpg" }, { "category_name":"Personal care", "category_id": 26, "category_icon":"/media/category_icon_upload_location/gillette-guard-3-card-blade-pack_rixer.png" } ] }, { "type": 2, "title":"Fresh Deals", "description":"Today's Arrival", "data": [ { "product_id": 193, "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF", "offer_price": 14500, "normal_price": 15500, "is_in_cart": false, "cart_qty": 0 }, { "product_id": 193, "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF", "offer_price": 14500, "normal_price": 15500, "is_in_cart": false, "cart_qty": 0 }, { "product_id": 193, "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF", "offer_price": 14500, "normal_price": 15500, "is_in_cart": false, "cart_qty": 0 } ] }, { "type": 3, "title":"", "description":"", "data": [ { "images":"/media/banner/Glocart%20Shop/Glocart-Shop_moVB3tP.jpg", "is_external": true, "link":"https://www.wikipedia.org/", "product_id": null, "offer_list_id": null, "product_list_id": null }, { "images":"/media/banner/Glocart%20Shop/Glocart-Shop_moVB3tP.jpg", "is_external": true, "link":"https://www.wikipedia.org/", "product_id": null, "offer_list_id": null, "product_list_id": null } ] }, { "type": 4, "title":"", "description":"", "data": [ { "images":"/media/banner/Glocart%20Shop/Glocart-Shop_moVB3tP.jpg", "is_external": true, "link": null, "product_id": null, "offer_list_id": null, "product_list_id": null } ] }, { "type": 5, "title":"Discount Range", "description":"", "data": [ { "banner":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "discount_from": 50, "discount_to": 60 }, { "banner":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "discount_from": 40, "discount_to": 100 } ] }, { "type": 2, "title":"Top Deals", "description":"Upto 45% discount", "data": [ { "product_id": 193, "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF", "offer_price": 14500, "normal_price": 15500, "is_in_cart": false, "cart_qty": 0 }, { "product_id": 193, "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF", "offer_price": 14500, "normal_price": 15500, "is_in_cart": false, "cart_qty": 0 }, { "product_id": 193, "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF", "offer_price": 14500, "normal_price": 15500, "is_in_cart": false, "cart_qty": 0 } ] }, { "type": 0, "title":"", "description":"", "data": { "images":"/media/banner/Glocart%20Shop/Glocart-Shop_moVB3tP.jpg", "is_external": true, "link":"https://www.wikipedia.org/", "product_id": null, "offer_list_id": null, "product_list_id": null } }, { "type": 6, "title":"Suggested for you", "description":"", "data": [ { "product_id": 193, "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF", "offer_price": 14500, "normal_price": 15500, "is_in_cart": false, "cart_qty": 0 }, { "product_id": 193, "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF", "offer_price": 14500, "normal_price": 15500, "is_in_cart": false, "cart_qty": 0 }, { "product_id": 193, "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF", "offer_price": 14500, "normal_price": 15500, "is_in_cart": false, "cart_qty": 0 } ] }, { "type": 0, "title":"", "description":"", "data": { "images":"/media/banner/Grocery/Grocery_m341Az6.jpg", "is_external": false, "link": null, "product_id": null, "offer_list_id": 1, "product_list_id": null } }, { "type": 7, "title":"", "description":"", "data": [ { "banner":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "category_name":"Personal Care", "category_id": 1, "have_sub_category": true, "sub_categories": [ { "category_name":"Chocolate", "category_id": 35, "category_icon":"/media/category_icon_upload_location/71p5hUVC0eL._SX569_.jpg" }, { "category_name":"Chocolate", "category_id": 35, "category_icon":"/media/category_icon_upload_location/71p5hUVC0eL._SX569_.jpg" } ] } ] }, { "type": 7, "title":"", "description":"", "data": [ { "banner":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "category_name":"Beauty Care", "category_id": 2, "have_sub_category": false, "sub_categories": [] } ] }, { "type": 7, "title":"", "description":"", "data": [ { "banner":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "category_name":"Home Care", "category_id": 3, "have_sub_category": false, "sub_categories": [] } ] } ], "cart_items_count": 5, "total_cart_price": 30000, "is_authenticated": true, "new_notification_count": 1, "cash_back_msg":"Dummy Cash Back message" } { "status": true, "error": false, "data": [ { "type": 0, "title":"", "description":"", "data": [ { "images":"/media/banner/Glocart%20Shop/Glocart-Shop_moVB3tP.jpg", "is_external": true, "link":"https://www.wikipedia.org/", "product_id": null, "offer_list_id": null, "product_list_id": null }, { "images":"/media/banner/Grocery/Grocery_m341Az6.jpg", "is_external": false, "link": null, "product_id": null, "offer_list_id": 1, "product_list_id": null } ] }, { "type": 1, "title":"Categories", "description":"", "data": [ { "category_name":"Beverages", "category_id": 5, "category_icon":"/media/category_icon_upload_location/61ho157I07L._SX522__WpWCZ7h.jpg" }, { "category_name":"Tea & Coffee", "category_id": 6, "category_icon":"/media/category_icon_upload_location/Lipton-Green-Tea-Bags-250-SDL859816919-1-31762.jpg" }, { "category_name":"Body Care", "category_id": 3, "category_icon":"/media/category_icon_upload_location/nourishing-body-lotion-100ml_1024x1024.png" }, { "category_name":"Personal Hygiene", "category_id": 7, "category_icon":"/media/category_icon_upload_location/lif0259_2_1.jpg" }, { "category_name":"Jams & Preserves", "category_id": 32, "category_icon":"/media/category_icon_upload_location/kissan-mixed-fruit-jam-500-gm-164390973-ymzpr.jpg" }, { "category_name":"Air Fresheners", "category_id": 28, "category_icon":"/media/category_icon_upload_location/Godrej_Aer_Home_Air_Freshener_Spray_Morning_Misty_Meadows__fkCoOzL.jpg" }, { "category_name":"Chocolate", "category_id": 35, "category_icon":"/media/category_icon_upload_location/71p5hUVC0eL._SX569_.jpg" }, { "category_name":"Cosmetics & Makeup", "category_id": 27, "category_icon":"/media/category_icon_upload_location/81oA3GcTyRL._SL1500_.jpg" }, { "category_name":"Personal care", "category_id": 26, "category_icon":"/media/category_icon_upload_location/gillette-guard-3-card-blade-pack_rixer.png" } ] }, { "type": 2, "title":"Fresh Deals", "description":"Today's Arrival", "data": [ { "product_id": 193, "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF", "offer_price": 14500, "normal_price": 15500, "is_in_cart": false, "cart_qty": 0 }, { "product_id": 193, "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF", "offer_price": 14500, "normal_price": 15500, "is_in_cart": false, "cart_qty": 0 }, { "product_id": 193, "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF", "offer_price": 14500, "normal_price": 15500, "is_in_cart": false, "cart_qty": 0 } ] }, { "type": 3, "title":"", "description":"", "data": [ { "images":"/media/banner/Glocart%20Shop/Glocart-Shop_moVB3tP.jpg", "is_external": true, "link":"https://www.wikipedia.org/", "product_id": null, "offer_list_id": null, "product_list_id": null }, { "images":"/media/banner/Glocart%20Shop/Glocart-Shop_moVB3tP.jpg", "is_external": true, "link":"https://www.wikipedia.org/", "product_id": null, "offer_list_id": null, "product_list_id": null } ] }, { "type": 4, "title":"", "description":"", "data": [ { "images":"/media/banner/Glocart%20Shop/Glocart-Shop_moVB3tP.jpg", "is_external": true, "link": null, "product_id": null, "offer_list_id": null, "product_list_id": null } ] }, { "type": 5, "title":"Discount Range", "description":"", "data": [ { "banner":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "discount_from": 50, "discount_to": 60 }, { "banner":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "discount_from": 40, "discount_to": 100 } ] }, { "type": 2, "title":"Top Deals", "description":"Upto 45% discount", "data": [ { "product_id": 193, "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF", "offer_price": 14500, "normal_price": 15500, "is_in_cart": false, "cart_qty": 0 }, { "product_id": 193, "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF", "offer_price": 14500, "normal_price": 15500, "is_in_cart": false, "cart_qty": 0 }, { "product_id": 193, "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF", "offer_price": 14500, "normal_price": 15500, "is_in_cart": false, "cart_qty": 0 } ] }, { "type": 0, "title":"", "description":"", "data": { "images":"/media/banner/Glocart%20Shop/Glocart-Shop_moVB3tP.jpg", "is_external": true, "link":"https://www.wikipedia.org/", "product_id": null, "offer_list_id": null, "product_list_id": null } }, { "type": 6, "title":"Suggested for you", "description":"", "data": [ { "product_id": 193, "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF", "offer_price": 14500, "normal_price": 15500, "is_in_cart": false, "cart_qty": 0 }, { "product_id": 193, "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF", "offer_price": 14500, "normal_price": 15500, "is_in_cart": false, "cart_qty": 0 }, { "product_id": 193, "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF", "offer_price": 14500, "normal_price": 15500, "is_in_cart": false, "cart_qty": 0 } ] }, { "type": 0, "title":"", "description":"", "data": { "images":"/media/banner/Grocery/Grocery_m341Az6.jpg", "is_external": false, "link": null, "product_id": null, "offer_list_id": 1, "product_list_id": null } }, { "type": 7, "title":"", "description":"", "data": [ { "banner":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "category_name":"Personal Care", "category_id": 1, "have_sub_category": true, "sub_categories": [ { "category_name":"Chocolate", "category_id": 35, "category_icon":"/media/category_icon_upload_location/71p5hUVC0eL._SX569_.jpg" }, { "category_name":"Chocolate", "category_id": 35, "category_icon":"/media/category_icon_upload_location/71p5hUVC0eL._SX569_.jpg" } ] } ] }, { "type": 7, "title":"", "description":"", "data": [ { "banner":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "category_name":"Beauty Care", "category_id": 2, "have_sub_category": false, "sub_categories": [] } ] }, { "type": 7, "title":"", "description":"", "data": [ { "banner":"/media/product_images/61XJQZV8YxL._SX425_.jpg", "category_name":"Home Care", "category_id": 3, "have_sub_category": false, "sub_categories": [] } ] } ], "cart_items_count": 5, "total_cart_price": 30000, "is_authenticated": true, "new_notification_count": 1, "cash_back_msg":"Dummy Cash Back message" } { 「ステータス」:true、 「エラー」:false、 "データ":[ {{ 「タイプ」:0、 "題名":""、 "説明":""、 "データ":[ {{ "画像":"/media/banner/Glocart%20Shop/Glocart-Shop_moVB3tP.jpg"、 "is_external":true、 "リンク":"https://www.wikipedia.org/"、 "product_id":null、 "offer_list_id":null、 "product_list_id":null }、 {{ "画像":"/media/banner/Grocery/Grocery_m341Az6.jpg"、 "is_external":false、 「リンク」:null、 "product_id":null、 "offer_list_id":1、 "product_list_id":null } ] }、 {{ 「タイプ」:1、 「タイトル」:「カテゴリ」、 "説明":""、 "データ":[ {{ "category_name":"飲料"、 "category_id":5、 "category_icon":"/media/category_icon_upload_location/61ho157I07L._SX522__WpWCZ7h.jpg" }、 {{ "category_name":"Tea&Coffee"、 "category_id":6、 "category_icon":"/media/category_icon_upload_location/Lipton-Green-Tea-Bags-250-SDL859816919-1-31762.jpg" }、 {{ "category_name":"ボディケア"、 "category_id":3、 "category_icon":"/media/category_icon_upload_location/nourishing-body-lotion-100ml_1024x1024.png" }、 {{ "category_name":"個人衛生"、 "category_id":7、 "category_icon":"/media/category_icon_upload_location/lif0259_2_1.jpg" }、 {{ "category_name":"Jams&Preserves"、 "category_id":32、 "category_icon":"/media/category_icon_upload_location/kissan-mixed-fruit-jam-500-gm-164390973-ymzpr.jpg" }、 {{ "category_name":"芳香剤"、 "category_id":28、 "category_icon":"/media/category_icon_upload_location/Godrej_Aer_Home_Air_Freshener_Spray_Morning_Misty_Meadows__fkCoOzL.jpg" }、 {{ "category_name":"チョコレート"、 "category_id":35、 "category_icon":"/media/category_icon_upload_location/71p5hUVC0eL._SX569_.jpg" }、 {{ "category_name":"Cosmetics&Makeup"、 "category_id":27、 "category_icon":"/media/category_icon_upload_location/81oA3GcTyRL._SL1500_.jpg" }、 {{ "category_name":"パーソナルケア"、 "category_id":26、 "category_icon":"/media/category_icon_upload_location/gillette-guard-3-card-blade-pack_rixer.png" } ] }、 {{ 「タイプ」:2、 「タイトル」:「フレッシュディール」、 「説明」:「今日の到着」、 "データ":[ {{ "product_id":193、 "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg"、 "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF"、 "offer_price":14500、 "normal_price":15500、 "is_in_cart":false、 "cart_qty":0 }、 {{ "product_id":193、 "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg"、 "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF"、 "offer_price":14500、 "normal_price":15500、 "is_in_cart":false、 "cart_qty":0 }、 {{ "product_id":193、 "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg"、 "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF"、 "offer_price":14500、 "normal_price":15500、 "is_in_cart":false、 "cart_qty":0 } ] }、 {{ 「タイプ」:3、 "題名":""、 "説明":""、 "データ":[ {{ "画像":"/media/banner/Glocart%20Shop/Glocart-Shop_moVB3tP.jpg"、 "is_external":true、"リンク":"https://www.wikipedia.org/"、 "product_id":null、 "offer_list_id":null、 "product_list_id":null }、 {{ "画像":"/media/banner/Glocart%20Shop/Glocart-Shop_moVB3tP.jpg"、 "is_external":true、 "リンク":"https://www.wikipedia.org/"、 "product_id":null、 "offer_list_id":null、 "product_list_id":null } ] }、 {{ 「タイプ」:4、 "題名":""、 "説明":""、 "データ":[ {{ "画像":"/media/banner/Glocart%20Shop/Glocart-Shop_moVB3tP.jpg"、 "is_external":true、 「リンク」:null、 "product_id":null、 "offer_list_id":null、 "product_list_id":null } ] }、 {{ 「タイプ」:5、 "タイトル":"割引範囲"、 "説明":""、 "データ":[ {{ "バナー":"/media/product_images/61XJQZV8YxL._SX425_.jpg"、 "discount_from":50、 "discount_to":60 }、 {{ "バナー":"/media/product_images/61XJQZV8YxL._SX425_.jpg"、 "discount_from":40、 "discount_to":100 } ] }、 {{ 「タイプ」:2、 「タイトル」:「お得な情報」、 「説明」:「最大45%割引」、 "データ":[ {{ "product_id":193、 "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg"、 "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF"、 "offer_price":14500、 "normal_price":15500、 "is_in_cart":false、 "cart_qty":0 }、 {{ "product_id":193、 "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg"、 "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF"、 "offer_price":14500、 "normal_price":15500、 "is_in_cart":false、 "cart_qty":0 }、 {{ "product_id":193、 "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg"、 "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF"、 "offer_price":14500、 "normal_price":15500、 "is_in_cart":false、 "cart_qty":0 } ] }、 {{ 「タイプ」:0、 "題名":""、 "説明":""、 "データ":{ "画像":"/media/banner/Glocart%20Shop/Glocart-Shop_moVB3tP.jpg"、 "is_external":true、 "リンク":"https://www.wikipedia.org/"、 "product_id":null、 "offer_list_id":null、 "product_list_id":null } }、 {{ 「タイプ」:6、 「タイトル」:「あなたに提案された」、 "説明":""、 "データ":[ {{ "product_id":193、 "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg"、 "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF"、 "offer_price":14500、 "normal_price":15500、 "is_in_cart":false、 "cart_qty":0 }、 {{ "product_id":193、 "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg"、 "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF"、 "offer_price":14500、 "normal_price":15500、 "is_in_cart":false、 "cart_qty":0 }、 {{ "product_id":193、 "image_url":"/media/product_images/61XJQZV8YxL._SX425_.jpg"、 "product_name":"UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF"、 "offer_price":14500、 "normal_price":15500、 "is_in_cart":false、 "cart_qty":0 } ] }、 {{ 「タイプ」:0、 "題名":""、 "説明":""、 "データ":{"画像":"/media/banner/Grocery/Grocery_m341Az6.jpg"、 "is_external":false、 「リンク」:null、 "product_id":null、 "offer_list_id":1、 "product_list_id":null } }、 {{ 「タイプ」:7、 "題名":""、 "説明":""、 "データ":[ {{ "バナー":"/media/product_images/61XJQZV8YxL._SX425_.jpg"、 "category_name":"パーソナルケア"、 "category_id":1、 "have_sub_category":true、 "sub_categories":[ {{ "category_name":"チョコレート"、 "category_id":35、 "category_icon":"/media/category_icon_upload_location/71p5hUVC0eL._SX569_.jpg" }、 {{ "category_name":"チョコレート"、 "category_id":35、 "category_icon":"/media/category_icon_upload_location/71p5hUVC0eL._SX569_.jpg" } ] } ] }、 {{ 「タイプ」:7、 "題名":""、 "説明":""、 "データ":[ {{ "バナー":"/media/product_images/61XJQZV8YxL._SX425_.jpg"、 "category_name":"ビューティーケア"、 "category_id":2、 "have_sub_category":false、 "sub_categories":[] } ] }、 {{ 「タイプ」:7、 "題名":""、 "説明":""、 "データ":[ {{ "バナー":"/media/product_images/61XJQZV8YxL._SX425_.jpg"、 "category_name":"在宅ケア"、 "category_id":3、 "have_sub_category":false、 "sub_categories":[] } ] } ]、 "cart_items_count":5、 "total_cart_price":30000、 "is_authenticated":true、 "new_notification_count":1、 "cash_back_msg":"ダミーのキャッシュバックメッセージ" } 作成しましたがエラーが表示されます

codable ios json swift

1
答える

コード化可能な構造体の@Published配列でのコード化可能な適合性

私はURLSessionをいじくり回していて、基本的にFacebookの友達リストのようなJSONファイルをContentViewにロードする非常にシンプルなアプリを構築していて、発生しているエラーではなく、内部のエラーを明確にしたいと考えていました。 SwiftのCADE-0の仕組み|プロトコル。コードと説明は次のとおりです。

swiftui struct codable swift urlsession

2
答え

同じフィールドに対して2つの可能なタイプを持つSwiftデコードJSON [重複]

この質問にはすでに回答があります: How to deal with completely dynamic JSON responses (3つの答え) 終了先月。 この質問にはすでに回答がありますこの質問にはすでに回答があります: How to deal with completely dynamic JSON responses完全に動的なJSON応答を処理する方法 (3つの答え) (3つの答え) 先月先月休業。 AlamofireとCodableを使用してこのJSONを処理しています:

alamofire ios swift codable json

ホットタグ

© 2021   KonnichiwaSekai.Com