https://github.com/silence0201/simodel
将JSON快速转换模型
https://github.com/silence0201/simodel
json
Last synced: about 1 year ago
JSON representation
将JSON快速转换模型
- Host: GitHub
- URL: https://github.com/silence0201/simodel
- Owner: silence0201
- License: mit
- Created: 2017-01-16T11:48:48.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-17T15:19:18.000Z (over 9 years ago)
- Last Synced: 2025-05-04T10:04:43.092Z (about 1 year ago)
- Topics: json
- Language: Objective-C
- Size: 240 KB
- Stars: 5
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SIModel


将JSON快速转换模型
使用说明
====
### 安装
##### 手工导入
将项目目录下的`SIModel`导入项目中
### 使用
1. 导入头文件
```objective-c
#import "NSObject+SIModel.h"
```
2. 建立模型对象,进行属性定义`(仅支持默认get和set方法)`
3. 如果`Array`中包含自定义`Class`,需要实现:
```objective-c
+ (NSDictionary *)si_clazzInArray{
return @{@"users":[User class]} ;
}
```
4. 如何属性名和JSON或字典中的key不相同,需要实现:
```objective-c
+ (NSDictionary *)si_replaceKeyFromPropertyName{
return @{
@"ID" : @"id" ,
@"desc" : @"desciption"
} ;
}
```
5. 过程处理
```objective-c
+ (void)si_beginObjectToModel:(id)obj{
NSLog(@"开始转换:%@",obj) ;
}
+ (void)si_endObjectToModel:(id)model{
NSLog(@"结束转换:%@",model) ;
}
```
6. 快速归档
```objective-c
@interface Members : NSObject
// 实现中添加
SIModelCodingImplementation
```
7. 更多请查看`NSObject+SIModel.h`说明
## SIModel
SIModel is available under the MIT license. See the LICENSE file for more info.