DynamicCodableKit

1.0.0

Implement dynamic JSON decoding within the constraints of Swift's sound type system by working on top of Swift's Codable implementations.
SwiftyLab/DynamicCodableKit

What's New

v1.0.0

2022-06-05T07:42:20Z

1.0.0 (2022-06-05)

✅ Tests

  • add DynamicDecodable unit tests (96d4ba6)
  • add tests for dynamic JSON decoding with type identifiers (9fc73b7)
  • add tests for dynamic JSON decoding with type(s) parent coding key (c222eb1)
  • add tests for dynamic JSON decoding with user context provider (74fd0b4)
  • add type identifier decoding tests (3ae17b3)

🚀 Features

  • add Carthage prebuilt frameworks support (c0f6918)
  • add Carthage support (107a5c7)
  • add CocoaPods support (4e53ceb)
  • add dynamic encoding (ac18636)
  • add dynamic JSON decoding with type identifiers (63bab18)
  • add dynamic JSON decoding with type(s) parent coding key (5c5bf0a)
  • add dynamic JSON decoding with user context provider (8a61ceb)
  • add ignoring key with invalid data for parent coding key based dynamic decoding (79935b4)

🐛 Fixes

  • CocoaPods: fix podspec source tag attribute (9072d1e)

📚 Documentation

  • add about and contributing guidelines (1c3f7d1)
  • add DocC documentation with articles (9575dd3)
  • add manual installation guides (c51c8c9)

💄 Styles

  • add swift-format for code formatting (0a719fe)

⏪ Reverts

  • Revert "chore: add single major swift tool package manifest" (19044fd)

DynamicCodableKit

API Docs CocoaPods Compatible Swift Package Manager Compatible Carthage compatible Swift Platforms CI/CD CodeQL codecov

DynamicCodableKit helps you to implement dynamic JSON decoding within the constraints of Swift's sound type system by working on top of Swift's Codable implementations.

The data types, protocols, and property wrappers defined by DynamicCodableKit can be used to provide dynamic decoding functionality to swift's Decodable types.

Features

  • Decode dynamic type based on JSON keys.
  • Decode dynamic type based on parent JSON key.
  • Dynamically decode types with default value if decoding fails.
  • Decode dynamic type array/set with option to ignore invalid elements.
  • Decode dynamic data based on user actions.

Requirements

Platform Minimum Swift Version Installation Status
iOS 8.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+ 5.1 CocoaPods, Carthage, Swift Package Manager, Manual Fully Tested
Linux 5.1 Swift Package Manager Fully Tested
Windows 5.1 Swift Package Manager Not Tested but Supported

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate DynamicCodableKit into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'DynamicCodableKit'

Optionally, you can also use the pre-built XCFramework from the GitHub releases page by replacing {version} with the required version you want to use:

pod 'DynamicCodableKit', :http => 'https://github.com/SwiftyLab/DynamicCodableKit/releases/download/v{version}/DynamicCodableKit-{version}.xcframework.zip'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate DynamicCodableKit into your Xcode project using Carthage, specify it in your Cartfile:

github "SwiftyLab/DynamicCodableKit"

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding DynamicCodableKit as a dependency is as easy as adding it to the dependencies value of your Package.swift.

.package(url: "https://github.com/SwiftyLab/DynamicCodableKit.git", from: "1.0.0"),

Optionally, you can also use the pre-built XCFramework from the GitHub releases page by replacing {version} and {checksum} with the required version and checksum of artifact you want to use:

.binaryTarget(name: "DynamicCodableKit", url: "https://github.com/SwiftyLab/DynamicCodableKit/releases/download/v{version}/DynamicCodableKit-{version}.xcframework.zip", checksum: "{checksum}"),

Manually

If you prefer not to use any of the aforementioned dependency managers, you can integrate DynamicCodableKit into your project manually.

Git Submodule

  • Open up Terminal, cd into your top-level project directory, and run the following command "if" your project is not initialized as a git repository:

    $ git init
  • Add DynamicCodableKit as a git submodule by running the following command:

    $ git submodule add https://github.com/SwiftyLab/DynamicCodableKit.git
  • Open the new DynamicCodableKit folder, and drag the DynamicCodableKit.xcodeproj into the Project Navigator of your application's Xcode project or existing workspace.

    It should appear nested underneath your application's blue project icon. Whether it is above or below all the other Xcode groups does not matter.

  • Select the DynamicCodableKit.xcodeproj in the Project Navigator and verify the deployment target satisfies that of your application target (should be less or equal).

  • Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the Targets heading in the sidebar.

  • In the tab bar at the top of that window, open the "General" panel.

  • Click on the + button under the Frameworks and Libraries section.

  • You will see DynamicCodableKit.xcodeproj folder with DynamicCodableKit.framework nested inside.

  • Select the DynamicCodableKit.framework and that's it!

    The DynamicCodableKit.framework is automagically added as a target dependency, linked framework and embedded framework in build phase which is all you need to build on the simulator and a device.

XCFramework

You can also directly download the pre-built artifact from the GitHub releases page:

  • Download the artifact from the GitHub releases page of the format DynamicCodableKit-{version}.xcframework.zip where {version} is the version you want to use.

  • Extract the XCFramework from the archive, and drag the DynamicCodableKit.xcframework into the Project Navigator of your application's target folder in your Xcode project.

  • Select Copy items if needed and that's it!

    The DynamicCodableKit.xcframework is automagically added in the embedded Frameworks and Libraries section, an in turn the linked framework in build phase.

Usage

See the full documentation for API details and articles on sample scenarios.

Contributing

If you wish to contribute a change, suggest any improvements, please review our contribution guide, check for open issues, if it is already being worked upon or open a pull request.

License

DynamicCodableKit is released under the MIT license. See LICENSE for details.

Description

  • Swift Tools 5.6.0
View More Packages from this Author

Dependencies

Last updated: Sun Mar 17 2024 10:59:23 GMT-0900 (Hawaii-Aleutian Daylight Time)