Skip to main content
Filter by
Sorted by
Tagged with
2 votes
1 answer
223 views

How do you make a UIView Codable under Swift 6 concurrency? To see the problem, start with this: final class MyView: UIView { var name: String init(name: String) { self.name = name ...
matt's user avatar
  • 540k
0 votes
0 answers
100 views

I have a "Course" struct that is used in decoding certain JSON values: struct Course: Decodable, Identifiable { var name: String? var courseCode: String var id: Int var ...
QuantumBlink's user avatar
2 votes
4 answers
169 views

I have a Swift class that may or may not be Codable. When it is Codable, I would like to be able to load it from file. Here is a bare bones example... protocol P { func load() } final class A<...
Drew McCormack's user avatar
0 votes
0 answers
68 views

I am currently trying to parse a nested dictionary response using Codable and trying to not use too much custom decoders. JSON response looks similar to below: { "id": "1234", &...
user5381191's user avatar
0 votes
0 answers
54 views

I receive server response which contains geojson I need to have the geojson as string and don't want to decode it, but this code throws type mismatch exception. init(from decoder: Decoder) throws { ...
Zahid's user avatar
  • 1
1 vote
1 answer
41 views

I am facing issues while using init(from decoder: Decoder) in Model extension in different module. I have model in Module 1 as below public struct LabelModel { public var value: String? } And I ...
Asif Raza's user avatar
  • 1,040
2 votes
4 answers
134 views

Consider the following JSON: { "jsonName": "fluffy", "color1": "Blue", "color2": "Red", "color3": "Green", &...
alex17's user avatar
  • 21
3 votes
1 answer
120 views

extension KeyedDecodingContainer { func decode(_: Money.Type, forKey key: Key) throws -> Money { let str = try decode(String.self, forKey: key) return try str.toMoney(on: key) ...
Roman's user avatar
  • 1,520
0 votes
1 answer
44 views

I am using the Unsplash API and it gives this response (which is just a snapshot) "exif": { "name": "Canon, EOS 6D" }, "location": { ...
Daniel Crompton's user avatar
1 vote
1 answer
56 views

I'm trying to map the following JSON { "items": [ { "id": 4, "name": "Caffè", "is_active": true, ...
Giorgio's user avatar
  • 2,250
0 votes
1 answer
138 views

Consider the following type: public struct DocumentDate: Codable { /// Year component of the date, Integer with no limitation on the range. public let year: Int /// Month component of the ...
Richard Topchii's user avatar
3 votes
2 answers
193 views

import Foundation let json = """ { "property": null } """.data(using: .utf8)! struct Program<T: Decodable>: Decodable { let property: T ...
Roman's user avatar
  • 1,520
-1 votes
1 answer
65 views

I'm encountering an issue while working on my Swift project that involves using the SwiftyUserDefaults library. I'm relatively new to Swift development and would appreciate some guidance on resolving ...
Ahmad's user avatar
  • 1
1 vote
1 answer
164 views

I have a JSON object which I want to decode into a struct. The JSON has similar key:value pairs for ingredients and measurements. I'd like to condense the ingredient and measurement information into ...
Anonymous Nancy's user avatar
0 votes
0 answers
88 views

I am passing a generic Decodable struct with parameter. Here is the struct code .. struct NameStruct<T: Decodable>: Decodable { // properties of the struct with property.. let values:...
user avatar
0 votes
1 answer
51 views

I have come across a key type in the JSON added bellow, { "id": "B2CAA3C8-077B-4A49-B5BA-206709630138", "markAsDoneDate": null, "endDate": 735025126....
SM Arif Ahmed's user avatar
0 votes
0 answers
61 views

I am new in SWIFT. I have been fighting with swift for a long time to decode my custom JSON. But I couldn't. This is my JSON : tablesArray is an array and it has more than one tables as jsonobject But ...
Murat's user avatar
  • 3
0 votes
0 answers
58 views

I am currently refactoring authentication for an iOS app in SwiftUI and I am having trouble getting the data associated with a new user saved to the backend API. Essentially when the user signs up, ...
user16961399's user avatar
1 vote
0 answers
43 views

I am getting an error when I am going to decode data response which contains escaping character string . To demonstrate, I created a playground. import Foundation struct Example: Decodable { let ...
SYL's user avatar
  • 11
2 votes
1 answer
164 views

I just tried this: let test = "{ \"de\": \"Bisasam\", \"en\": \"Bulbasaur\" }" let data = test.data(using: .utf8)! do { let result = try ...
JamesDerrick248's user avatar
0 votes
1 answer
207 views

I am currently trying to make an extension to render CLLocation codable. To do so, I am trying to replicate the example on this thread: Swift - Codable Decode array of arrays of CLLocation I have the ...
user avatar
0 votes
1 answer
434 views

This is the first time I have tried to use an API, I get the error "keyNotFound" Could someone point me in the right direction for understanding this better? Here is a link to their ...
Steve's user avatar
  • 1,171
0 votes
2 answers
101 views

Say I have to send this data to the server: struct Event: Codable { let title: String let params: [String:Any]? //Not allowed } So for instance, these events could look like any of these: let ...
soleil's user avatar
  • 13.3k
0 votes
4 answers
151 views

I have a WebAPI which returns JSON like the following: {"result":"true","message":"2023-07-01 16:09:02"} I have a Decodable object defined like this: struct ...
raddevus's user avatar
  • 9,296
0 votes
2 answers
415 views

I have a struct UISectionModel with only one property section, which has a protocol UISectionProtocol for a type, as follows: struct UISectionModel: Codable { let section: UISectionProtocol } ...
vintinhum's user avatar
0 votes
1 answer
303 views

I have an API response that is returning a list of objects that are sometimes different and I am having issues trying to decode the list properly. The list will have the object type as the key and ...
Noah Iarrobino's user avatar
0 votes
2 answers
141 views

My app gets its data from an API endpoint. The data is a Review and the model looks like this: struct Review: Identifiable, Decodable { var id: Int var reviewable_type: String var score: ...
Remi's user avatar
  • 49
2 votes
2 answers
129 views

Suppose I have the following struct definition and dictionary: struct Point: Codable { let x: Int let y: Int } let pointDictionary = [ "x": 0, "y": 1] // Inital example ...
idz's user avatar
  • 13k
0 votes
1 answer
570 views

I have a json like below need to parse , I have looked into many solutions . Here I need to use the value of the start key to fetch next value . "journey": { "start"...
Vishnu's user avatar
  • 208
-1 votes
1 answer
74 views

I need structs to decode surface wind data. https://api.windy.com/point-forecast/docs The body of response from API docs: { ts:int[], units: { {parameter-level}: string, {...
Andy's user avatar
  • 37
2 votes
1 answer
455 views

I have a some nested swift classes that are automatically decoded from JSON using the Decodable protocol. Everything works except this one enum. The json data is a capitalised string of either Open or ...
Darren's user avatar
  • 10.5k
1 vote
1 answer
680 views

The two structs that I am using are Scoreboard and ResultSet struct ResultSet: Codable { var name: String var headers: [String] //var rowSet: [String] } struct Scoreboard: Codable { ...
Omar Ebrahim's user avatar
0 votes
2 answers
2k views

I'm trying to decode a JSON response as a custom type, that I believe conforms to Decodable. These are the codable structs that I am using struct ResultSet: Codable { var name: String var ...
Omar Ebrahim's user avatar
1 vote
1 answer
428 views

I receive the following JSON from API { "someProperty":"someValue", "type":"type1", "values":{ "first":"someValue", ...
Nik's user avatar
  • 13
0 votes
1 answer
526 views

I have a JSON file and I want to use [String: Any]. The problem I'm having is that I get an error: No exact matches in call to instance method 'decode' I would love to understand where I am wrong. ...
soso22's user avatar
  • 1
0 votes
1 answer
199 views

I was trying to perform some tests on JSONDecoder and I've encountered a strange behavior. In particular, when I use the following code an error is thrown. let data = "Sample String".data(...
Lorenzo B's user avatar
  • 33.4k
-1 votes
2 answers
103 views

I am trying to understand what is going on in my code here. I have a simple API call to open weahter API and that whenever the user taps the UIButton, it should call the api and get the data back from ...
SushiRiceOverEggs's user avatar
0 votes
2 answers
705 views

I am getting dates from server in below format "endTime": "2022-12-12T16:20:00.000Z" I am using Codable to parse json to Objects. I am using a custom decoder shown below internal ...
rohit phogat's user avatar
0 votes
0 answers
58 views

I have my struct as: struct CategoryViewModel2: Codable { let data: [Datum2]? } // MARK: - Datum struct Datum2: Codable { let the0: Int? let the1, the2: String? let the3, the4, id: ...
Kuldeep Vashist's user avatar
0 votes
1 answer
706 views

I'm encountering some weird edge cases when parsing JSON data from the Google search autocomplete API. This is my model for decoding the JSON data: struct suggestOutputModel: Decodable { let query:...
mingwei's user avatar
  • 113
0 votes
1 answer
53 views

import UIKit class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { var hero = [HeroStruct]() @IBOutlet weak var tableView: UITableView! override func ...
7mach's user avatar
  • 43
-1 votes
1 answer
691 views

Other suggested solutions handle type of structure they are part of, While I am not able to figure out how to parse nested part of that same structure based on the value within outer structure. I have ...
Dushyant Deshwal's user avatar
0 votes
0 answers
147 views

I am trying to get JSON from an external source, using AlamoFire tools. Using the .responseJSON method works, but that will be deprecated and in any case I know .responseDecodable is more sound. ...
libhut-samwes's user avatar
2 votes
1 answer
1k views

I have a Type called ObjectAPIModel that explicitly conforms to the Codable protocol. I also do have a function which receives some data and calls another function to decode any JSON to a specified ...
olvrwn's user avatar
  • 117
1 vote
3 answers
745 views

Here's my problem. Let's say I have a JSON structure that I'm reading using Swift's Codable API. What I want to do is not decode part of the JSON but read it as a string even though it's valid JSON. ...
drekka's user avatar
  • 22.1k
0 votes
0 answers
38 views

My process is I have bunch of json string that I need to convert into request payload and make a POST request to api call. The issue is key may or may not exist from my original json string and the ...
jacobcan118's user avatar
  • 9,339
0 votes
1 answer
177 views

I have this API response structure (from Strapi v4): { "data": [ { "id": 1, "attributes": { "description": &...
heyfrank's user avatar
  • 5,694
0 votes
1 answer
558 views

Background: I'm using swift [email protected] and I need to parse json data AF.request("https://xxx.json").validate().responseDecodable(of: Decodable) The data looks like: [ [ "...
divflex's user avatar
0 votes
1 answer
254 views

I have a Decodable to which I want to add one extra property, not present in the plist. The code below seems to work. I'm not sure why, since it no longer conforms to the plist. Can anyone explain? Is ...
Daan's user avatar
  • 1,437
0 votes
2 answers
621 views

Well guys like the title says i have on a response service call an JSON array and i cant find the way to decode with Combine: URLSession.shared.dataTaskPublisher Service Response: https://codebeautify....
coden0w's user avatar
  • 31

1
2 3 4 5
14