Skip to content

rajagp/iOS_swift_codables

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iOS_swift_codables

Swift Playground for Exploring Swift4 Codables for JSON Parsing

Requirements

  • Xcode 9 and above
  • Swift 4

To Begin

  • Open SwiftCodables.playground in Xcode
  • Start with Toc.xcplayground page which from where you can navigate to the other playground pages. Make sure you check the Render Documentation checkbox.

Execution

  • Navigate to the playground that you want to Execute a playground by clicking on the "Run" button

Examples

Examples demonstrating transformation between JSON and Swift native types using swift4 Codables. Each chapter looks at various use cases.

  • The Basics
    • The examples introduce the Swift Encodable and Decodable protocols
  • Date
    • The example discuss the use of built in Date encoders/decoders
  • Simple Custom Codable Type
    • The examples discuss the use of nested Codable types
  • Introduction to Codable Keys
    • The examples introduce the CodableKey protocol and how you can use it to specify the mapping of JSON-native properties
  • Containers
    • The examples introduce the concept of Containers includeing KeyedContainer, UnkeyedContainer and ValueContainer
  • Changing Types
    • The examples demonstrate how you can change the type of a property to an appropriate native type when it is tranformed to a swift type and back
  • Flattening Types
    • The examples demonstrate how you can flatten a nested JSON object when converting to native type
  • Associative Enums
    • The examples demonstrate the encoding / decoding of a swift associative enum type to correpsonding JSON types
  • Subclasses
    • The examples demonstrate the encoding/decoding of native subclasses to corresponding JSON types
  • Dynamic Coding Keys
    • The examples demonstrate the encoding / decoding JSON objects that hold dynamic set of keys
  • Context
    • The examples demonstrate the use of context data for encoding/decoding
  • All Together
    • A more complete example that puts together all the concepts showcased in previous examples

About

A playground for testing Swift4 Codables for JSON Parsing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages