A Swift library for type-safe extraction and conversion of values from [String: Any] dictionaries like JSON and plists.
Marshal is a Swift library designed for type-safe extraction and conversion of values from loosely typed data structures like [String: Any] dictionaries, JSON, and plists. It solves the problem of dealing with typeless data in a declarative and error-handled way, eliminating the need for complex monads or reflection-based magic. By leveraging Protocol Oriented Programming, it allows developers to easily marshal and unmarshal data between dictionaries and Swift models.
iOS, watchOS, tvOS, and macOS developers working with JSON, plists, or other [String: Any] data who need a type-safe, explicit, and performant way to serialize and deserialize data without relying on reflection.
Developers choose Marshal for its explicit, declarative approach that avoids the pitfalls of reflection, provides full control over serialization formats (like snake_case or camelCase), and delivers strong performance with comprehensive error handling. Its protocol-oriented design makes it easy to extend for custom types while maintaining simplicity and type safety.
Marshaling the typeless wild west of [String: Any]
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Enables extraction of native Swift types from nested dictionaries using dot notation, such as `json.value(for: "user.website")`, ensuring compile-time safety without reflection.
Simplifies model creation by conforming to the Unmarshaling protocol with a straightforward initializer, as shown in the User struct example for converting [String: Any] to Swift models.
Allows adding support for complex types like Date by implementing ValueType, providing flexibility for custom parsing logic without modifying the core library.
Offers Marshaling protocol for converting models back to dictionaries with full control over key names and formats, avoiding magic reflection as emphasized in the README.
Requires writing initializers and marshaling methods for each model, unlike Codable which auto-synthesizes code, increasing development overhead for simple cases.
Does not support common complex types like Date natively, forcing developers to implement custom extensions for basic functionality, as admitted in the README.
Has fewer contributors and less community support compared to popular alternatives like SwiftyJSON, which may impact long-term maintenance and third-party integrations.