AnyCoatyObjectDecodable
public class AnyCoatyObjectDecodable : Decodable
Supports decoding of any Coaty object, either as a core type or as a custom, i.e application-specific object type.
If the Coaty object type specified in the decodable JSON object has been registered as a Swift class, an instance of the corresponding class type is created with all core type and custom type properties filled in. Any extra fields present on the decodable object are ignored.
Otherwise, if the Coaty object type has not been registered, an instance of the core type class as specified
in the decodable JSON object is created with all core type properties filled in. Additionally, any other field
present on the decodable object is added to the custom
dictionary property of the created instance.
The second approach is especially useful if you want to observe custom Coaty objects whose object type is not known at compile time so that no Swift class definition exists for them.
Note
the created Coaty object instance is accessible by theobject
property.
-
Supports decoding of any Coaty object, either as a core type or as a custom, i.e application-specific object type.
If the Coaty object type specified in the decodable JSON object has been registered as a Swift class, an instance of the corresponding class type is created with all core type and custom type properties filled in. Any extra fields present on the decodable object are ignored.
Otherwise, if the Coaty object type has not been registered, an instance of the core type class as specified in the decodable JSON object is created with all core type properties filled in. Additionally, any other field present on the decodable object is added to the
custom
dictionary property of the created instance.The second approach is especially useful if you want to observe custom Coaty objects whose object type is not known at compile time so that no Swift class definition exists for them.
Note
the created Coaty object instance is accessible by theobject
property.Declaration
Swift
required public init(from decoder: Decoder) throws