Type-Preserving-Coding-Adapter | preserve types of your classes ancestors
kandi X-RAY | Type-Preserving-Coding-Adapter Summary
kandi X-RAY | Type-Preserving-Coding-Adapter Summary
Adapter to preserve types of your classes ancestors when coding or hide objects behind a protocol
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Type-Preserving-Coding-Adapter
Type-Preserving-Coding-Adapter Key Features
Type-Preserving-Coding-Adapter Examples and Code Snippets
Community Discussions
Trending Discussions on Type-Preserving-Coding-Adapter
QUESTION
The problem: decode an array of objects belonging to Parent and Child classes.
I read a lot of stuff on this subject but I have not been able to find a simple solution.
I encoded a type property which provide the information of the original class, but I haven't found a way to use it in decoding the object.
...ANSWER
Answered 2020-Oct-03 at 12:45I think a major part of the problem is that you are using an array of mixed types, [Any], and then you are decoding it as one type Parent because it is quite possible to get the child objects to be properly encoded as Child.
One solution is to create a new Codable struct that holds the array and that with the use of a type property keeps track on how to decode the objects in the array
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Type-Preserving-Coding-Adapter
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page