Parse a JSON API response into a typed Swift model object with one function call instead of writing repetitive decoding code.
Convert a nested Swift object tree, a User containing a list of Friend objects each with an Address, from a single JSON payload.
Transform raw JSON values like date strings into Swift Date objects using custom transformations before use.
Build Swift models with constant let properties from JSON using the ImmutableMappable protocol.
Add via CocoaPods, Carthage, or Swift Package Manager, works with any iOS or macOS Xcode project.
ObjectMapper is a Swift library for iOS and macOS development that handles the conversion between JSON data and Swift objects. JSON is the format most web APIs use to send data back and forth, and without a library like this, translating that raw data into usable Swift objects requires writing a lot of repetitive code by hand. ObjectMapper reduces that to a few lines. The core idea is that you define a model, which is just a description of what your data looks like, and then annotate it to tell ObjectMapper which JSON fields correspond to which properties. Once that mapping is defined, converting a JSON string to an object or converting an object back to JSON becomes a single function call. The library uses a custom operator to express these mappings in a compact, readable way. ObjectMapper handles a wide range of data types: numbers, strings, booleans, arrays, dictionaries, enums, and nested objects. If you have a User object that contains a list of Friend objects, and each Friend has an Address object, ObjectMapper can build that whole structure from a single JSON payload. It also supports custom transformations for cases where the raw JSON value needs to be converted before use, such as turning a date string into an actual Date object. The library offers several protocols to cover different coding styles. The standard Mappable protocol works for most cases. StaticMappable is available when you need to control how objects are created, for instance to pick a subclass based on what is in the JSON. ImmutableMappable is for situations where you want your model properties to be constants rather than variables, which is a common preference in Swift. Installation is handled through CocoaPods, Carthage, or Swift Package Manager, which are the standard dependency tools in the Apple ecosystem. The project also documents how to use ObjectMapper alongside Alamofire, a popular networking library, and Realm, a mobile database, making it easier to slot into a typical iOS app setup.
← tristanhimmelman on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.