Utility
public class Utility
A utility class providing helper methods for JSON decoding with detailed error reporting.
-
Decodes a
Decodabletype from JSON data with comprehensive error logging.This method attempts to decode the provided data and logs detailed error information if decoding fails, including:
- Data corruption contexts
- Missing keys with their coding paths
- Value not found errors with types and paths
Type mismatch errors with expected types and paths
Declaration
Swift
public static func decode<T>(_ decodable: T.Type, from data: Data) -> T? where T : DecodableParameters
decodableThe type to decode to
dataThe JSON data to decode from
Return Value
An instance of the decoded type, or
nilif decoding fails
View on GitHub