Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. iOS
  3. CodableAlamofire

CodableAlamofire

MITSwift1.2.1

An Alamofire extension that seamlessly converts JSON responses into Swift Decodable objects.

GitHubGitHub
735 stars53 forks0 contributors

What is CodableAlamofire?

CodableAlamofire is a Swift library that extends Alamofire to automatically convert JSON API responses into Swift Decodable objects. It leverages Swift's Codable protocol to eliminate manual JSON parsing, making network requests more type-safe and reducing boilerplate code. This library simplifies integrating network calls with Swift's modern serialization features.

Target Audience

Swift developers building iOS, macOS, tvOS, watchOS, or Linux applications who use Alamofire for networking and want to adopt Codable for JSON handling. It's ideal for those seeking to write cleaner, more maintainable network layer code.

Value Proposition

Developers choose CodableAlamofire because it seamlessly integrates Alamofire with Swift's Codable protocol, offering a concise and type-safe way to handle JSON responses. Its keyPath support and custom decoder options provide flexibility without sacrificing the simplicity of automatic decoding.

Overview

An extension for Alamofire that converts JSON data into Decodable objects.

Use Cases

Best For

  • Swift projects using Alamofire that need automatic JSON-to-object mapping
  • Reducing boilerplate code in network layers with type-safe responses
  • Handling nested JSON structures with keyPath decoding
  • Integrating custom date formats or other decoding strategies in API calls
  • Building cross-platform Swift applications (iOS, macOS, tvOS, watchOS, Linux) with consistent networking
  • Migrating legacy Alamofire code to use Swift's modern Codable protocol

Not Ideal For

  • Projects not using Alamofire (e.g., those on URLSession or other networking libraries)
  • Teams preferring comprehensive solutions like Moya that bundle Codable support with additional abstractions
  • Applications with non-JSON APIs (e.g., XML, Protobuf) as it's JSON-specific
  • Projects aiming for minimal dependencies where adding Alamofire and this extension is overkill for simple requests

Pros & Cons

Pros

Automatic JSON Decoding

Provides a `responseDecodableObject` method that automatically decodes JSON into Decodable types, eliminating manual parsing as demonstrated in the README with the Repo struct example.

Flexible KeyPath Support

Allows specifying keyPaths to decode nested JSON objects, making it easy to extract specific data structures like 'result.libraries' without extra mapping code.

Custom Decoder Integration

Supports custom JSONDecoder configurations, such as date decoding strategies (e.g., .secondsSince1970), enabling flexible parsing tailored to API requirements.

Type-Safe Networking

Leverages Swift's Codable protocol for compile-time safety, reducing runtime errors by ensuring response data matches expected types like Repo or [Repo].

Cross-Platform Compatibility

Works across iOS, macOS, tvOS, watchOS, and Linux, ensuring broad usability in Swift projects as highlighted in the platform badges.

Cons

Alamofire Dependency Lock-in

Ties your project to Alamofire; if you need to switch networking libraries or reduce dependencies, you'll have to rewrite the network layer and lose this convenience.

Limited to JSON Format

Focuses solely on JSON decoding, so it's unsuitable for APIs using other data formats like XML or binary, requiring additional workarounds.

Overhead for Simple Use Cases

For basic networking tasks, the combination of Alamofire and this extension adds unnecessary complexity and bundle size compared to using URLSession directly with Codable.

KeyPath Complexity

While powerful, keyPath support can introduce complexity and potential errors when dealing with deeply nested or dynamic JSON structures, as noted in the README's array vs. object handling.

Frequently Asked Questions

Quick Stats

Stars735
Forks53
Contributors0
Open Issues1
Last commit4 years ago
CreatedSince 2017

Tags

#ios#codable#alamofire#swift4#type-safe#mapping#json-parsing#swift#json#parsing-library#http-client#macos#decodable#networking

Built With

S
Swift

Included in

iOS51.7k
Auto-fetched 1 day ago

Related Projects

SwiftyJSONSwiftyJSON

The better way to deal with JSON data in Swift.

Stars22,957
Forks3,431
Last commit2 months ago
MantleMantle

Model framework for Cocoa and Cocoa Touch

Stars11,261
Forks1,468
Last commit3 years ago
ObjectMapperObjectMapper

Simple JSON Object mapping written in Swift

Stars9,154
Forks1,029
Last commit2 years ago
MJExtensionMJExtension

A fast, convenient and nonintrusive conversion framework between JSON and model. Your model class doesn't need to extend any base class. You don't need to modify any model file.

Stars8,507
Forks2,138
Last commit2 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub