Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

swift convert data to dictionary

do {
let json = try JSONSerialization.jsonObject(with: jsonData, options: [])
}
catch let e{ print(e.localizedDescription) }
Comment

swift convert data to dictionary

do{  
let json = try JSONSerialization.jsonObject(with: data!, options: []) as? [String : Any]
}catch{ print("erroMsg") }
Comment

swift string to dictionary

func convertStringToDictionary(text: String) -> [String:AnyObject]? {
    if let data = text.data(using: .utf8) {
        do {
            let json = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String:AnyObject]
            return json
        } catch {
            print("Something went wrong")
        }
    }
    return nil
}
Comment

PREVIOUS NEXT
Code Example
Swift :: struct vs enum swift 
Swift :: uiimage to data swift 
Swift :: struct to json convert in swift 
Swift :: swift hex color 
Swift :: swift add programmatically width height constraint to view 
Swift :: power swift 
Swift :: how to set the center in view in swift 
Swift :: swift loop through 2 arrays at once 
Swift :: standard bank swift code 
Swift :: set white place holder color in swift 
Swift :: swiftui popover 
Swift :: sf symbols 
Swift :: set font uilabel swift 
Swift :: add callbacks to view swiftui 
Swift :: how to show notification icon on tabbar item swift 
Swift :: how to center vertically scrollview swiftui 
Swift :: uilabel center text programmatically swift 
Swift :: swiftui rounded specific corner 
Swift :: Swift How to declare an optional in Swift? 
Swift :: printf in swift 
Swift :: Swift guard Vs if Statement 
Swift :: how to scroll to section in tableview swift 
Swift :: Swift Function With inout Parameters 
Swift :: appendBytes: Lengt: SWIFT 
Swift :: swiftui button only text tappable 
Swift :: how to use IBOutlet variables as static in swift 
Swift :: convert dictionary to data 
Swift :: Swift Conforming Multiple Protocols 
Swift :: how to do corner radius from button image in swift 
Ruby :: ERROR: While executing gem ... (Gem::FilePermissionError) 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =