Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/liangdahong/BMExport
Browse files Browse the repository at this point in the history
* 'master' of https://github.com/liangdahong/BMExport:
  Update README.md
  Update README.md
  Update README.md
  Update README.md
  Update README.md
  Update README.md
  • Loading branch information
liangdahong committed Aug 14, 2020
2 parents 785a111 + 00c90bd commit 54fe295
Showing 1 changed file with 78 additions and 3 deletions.
81 changes: 78 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,96 @@
# 一个 JSON 转 Objective-C Model 属性的 Mac 小工具。
# 一个 JSON 转 Model 属性的 Mac 小工具,目前支持 Objective-C,Swift class, Swift struct

> 自动将 JSON 转换为 Model 属性代码,支持自动对齐(强迫症的最爱,不在敲空格了哈)和添加注释(注释是给别人看的哈, 自己以后看也轻松)
- 【点击直接下载 https://github.com/liangdahong/BMExport/raw/master/dmg.dmg 】。

![](1.gif)
<img width="80%" src="https://user-images.githubusercontent.com/12118567/90214199-58ead880-de2a-11ea-814a-ff87765d4bb6.gif"/>

# 当前功能
- JSON -> Model 属性代码
- 添加注释占位
- 属性对齐
- 目前解析 JSON 是独立模块,所以支持其他语言也很简单,只需要编写相关其他语言的特性代码即可。
- 支持 swift 只需如下代码即可:
![image](https://user-images.githubusercontent.com/12118567/90214567-82f0ca80-de2b-11ea-8265-c4b08817674e.png)
```OBJC
switch (obj.propertyType) {
case BMPropertyTypeInt:
[propertyArray addObject:[NSString stringWithFormat:@"var %@ = 0",
obj.propertyName]];
break;
case BMPropertyTypeBoolean:
[propertyArray addObject:[NSString stringWithFormat:@"var %@ = false",
obj.propertyName]];
break;
case BMPropertyTypeString:
[propertyArray addObject:[NSString stringWithFormat:@"var %@ = \"\"",
obj.propertyName]];
break;
case BMPropertyTypeArray:
[propertyArray addObject:[NSString stringWithFormat:@"var %@: Array<<#type#>> = []",
obj.propertyName]];
break;
case BMPropertyTypeDictionary:
[propertyArray addObject:[NSString stringWithFormat:@"var %@: <#type#>?",
obj.propertyName]];
break;
case BMPropertyTypeObject:
[propertyArray addObject:[NSString stringWithFormat:@"var %@: <#type#>?",
obj.propertyName]];
break;
default:
break;
}
```
- 支持 Objective-C 只需如下代码即可:
![image](https://user-images.githubusercontent.com/12118567/90214557-78cecc00-de2b-11ea-954a-f022487fb097.png)
```OBJC
switch (obj.propertyType) {
case BMPropertyTypeInt:
[propertyArray addObject:[NSString stringWithFormat:@"@property (nonatomic, assign) NSInteger %@;",
obj.propertyName]];
break;
case BMPropertyTypeBoolean:
[propertyArray addObject:[NSString stringWithFormat:@"@property (nonatomic, assign) BOOL %@;",
obj.propertyName]];
break;
case BMPropertyTypeString:
[propertyArray addObject:[NSString stringWithFormat:@"@property (nonatomic, copy) NSString *%@;",
obj.propertyName]];
break;
case BMPropertyTypeArray:
[propertyArray addObject:[NSString stringWithFormat:@"@property (nonatomic, copy) NSArray <<#type#> *> *%@;",
obj.propertyName]];
break;
case BMPropertyTypeDictionary:
[propertyArray addObject:[NSString stringWithFormat:@"@property (nonatomic, strong) <#type#> *%@;",
obj.propertyName]];
break;
case BMPropertyTypeObject:
[propertyArray addObject:[NSString stringWithFormat:@"@property (nonatomic, strong) <#type#> *%@;",
obj.propertyName]];
break;
default:
break;
}
```

# 联系
- 欢迎 [issues](https://github.com/liangdahong/BMExport/issues)[PR](https://github.com/liangdahong/BMExport/pulls)
- 也可以添加微信<img width="20%" src="https://user-images.githubusercontent.com/12118567/86319172-72fb9d80-bc66-11ea-8c6e-8127f9e5535f.jpg"/> 进微信交流群。
# 计划
- 支持 `Swift`
- 支持自动生成 `Model` 文件
- 按属性类型排序等
- 网页版工具
Expand Down

0 comments on commit 54fe295

Please sign in to comment.