Coder Social home page Coder Social logo

liangdahong / bmexport Goto Github PK

View Code? Open in Web Editor NEW
22.0 1.0 0.0 6.84 MB

一个 JSON 转 Objective-C,Swift class, Swift struct Model 属性的 Mac 小工具,【点击直接下载 https://github.com/liangdahong/BMExport/releases/download/2.0/BMExport2.0.dmg 】。

License: MIT License

Objective-C 99.48% Ruby 0.15% C 0.37% Swift 0.01%
json model jsonmodel swift swiftmodel objective-c objective-c-extensions objc mjextension yymodel

bmexport's Introduction

一个 JSON 转 Model 属性代码的 Mac 小工具,目前支持 Objective-C,Swift class, Swift struct 。

当前功能

  • JSON -> Model 属性代码
  • 添加注释占位
  • 属性对齐
  • 目前解析 JSON 是独立模块,所以支持其他语言也很简单,只需要编写相关其他语言的特性代码即可。
  • 支持 Swift 只需如下代码即可: image
        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
        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;
        }

联系

  • 欢迎 issuesPR
  • 也可以添加微信 进微信交流群。

计划

  • 考虑支持 Swift 的相关 Model 解析框架,如:HandyJSON,ObjectMapper。
  • 支持自动生成 Model 文件;
  • 按属性类型排序等;
  • 尝试实现网页版工具;
  • 支持其他语言;
  • 等。

bmexport's People

Contributors

liangdahong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.