Skip to content

Dangerous json parse operation #9

@ftp27

Description

@ftp27

data: try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map, options: []))

Not long ago, I updated libraries and encountered a crash during the parsing attempt. My old implementation was harmless because, in the event of a failed parse, I would simply return nil from the init method. This occurred when the server processed new data, and a failed parse was necessary for filtration purposes. Now, we need to utilize this parser, which even doesn't provide me with the opportunity to handle errors. Is it possible to remove the exclamation mark (!) from this line?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions