Utility

public class Utility

A utility class providing helper methods for JSON decoding with detailed error reporting.

  • Decodes a Decodable type 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 : Decodable

    Parameters

    decodable

    The type to decode to

    data

    The JSON data to decode from

    Return Value

    An instance of the decoded type, or nil if decoding fails