This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Enum with type as type of the content | |
// Assciated value will hold the actual content data | |
enum BodyContent { | |
case number(Int) | |
case text(String) | |
case unsupported | |
} | |
// Now we can represent our Models as | |
struct Content: Decodable { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Content: Decodable { | |
var body: [Body] | |
} | |
struct Body: Decodable { | |
var type: String | |
var content: ??? | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"body":[ | |
{ | |
"type":"string", | |
"content":"Lorem ipsum text" | |
}, | |
{ | |
"type":"int", | |
"content":10 | |
} |
NewerOlder