Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/noppefoxwolf/codablemapper
Codableが出たのでORMを消し去ろうとして生まれたORMがコレ
https://github.com/noppefoxwolf/codablemapper
Last synced: 29 days ago
JSON representation
Codableが出たのでORMを消し去ろうとして生まれたORMがコレ
- Host: GitHub
- URL: https://github.com/noppefoxwolf/codablemapper
- Owner: noppefoxwolf
- License: mit
- Created: 2018-02-26T05:28:12.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-02-26T15:39:40.000Z (over 6 years ago)
- Last Synced: 2024-05-02T05:45:52.119Z (6 months ago)
- Language: Swift
- Homepage:
- Size: 25.4 KB
- Stars: 3
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CodableMapper
CodableMapper is a framework written in Swift that makes it easy for you to convert your decodable model objects (classes and structs) from JSON.
Inspired by ObjectMapper.## Features
- Mapping JSON to decodable objects
- Nested Objects
- Custom transformations during mapping
- Struct support## Usage
basic and transform
```
{
"id": 100,
"date": "2015/03/04 12:34:56 +09:00"
}
``````
struct Content: Decodable {
var id: Int = 0
var date: Date?
public init(from decoder: Decoder) throws {
id <- decoder["id"]
date <- (decoder["date"], DateTransform())
}
}
``````
let content = Content(JSONString: json)!
```## Nested value
nested json to flat.
```
{
"user": {
"id": 100
}
}
``````
struct User: Decodable {
var id: Int = 0
public init(from decoder: Decoder) throws {
id <- decoder["user.id"]
}
}
```## Example
look to tests.
## Requirements
Swift 4.0
## Installation
CodableMapper is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod 'CodableMapper'
```carthage
```
github 'noppefoxwolf/CodableMapper'
```## Author
Tomoya Hirano, [email protected]
## License
CodableMapper is available under the MIT license. See the LICENSE file for more info.