Giter Site home page Giter Site logo

驼峰命名的问题解决了吗,其实也不是太麻烦吧,比如“user_id”改成"userId",不一定要判断单词,也就是替换某些字符 about esjsonformat-xcode HOT 6 OPEN

enjoysr avatar enjoysr commented on September 10, 2024
驼峰命名的问题解决了吗,其实也不是太麻烦吧,比如“user_id”改成"userId",不一定要判断单词,也就是替换某些字符

from esjsonformat-xcode.

Comments (6)

wonderffee avatar wonderffee commented on September 10, 2024

为什么一定要用驼峰命名呢?是不是下划线不好?

from esjsonformat-xcode.

jkyin avatar jkyin commented on September 10, 2024

@wonderffee 规范化有利于协同开发。
@lyluoyuan 更规范的应该是 userID。

from esjsonformat-xcode.

EnjoySR avatar EnjoySR commented on September 10, 2024

待我12月20号之后改~~~非常抱歉~~

from esjsonformat-xcode.

EnjoySR avatar EnjoySR commented on September 10, 2024

不过只能支持 user_id 这种, 不然每一个驼峰片断不好匹配判断

from esjsonformat-xcode.

maplelover avatar maplelover commented on September 10, 2024
  • (NSString *)camelFromUnderline
    {
    if (self.length == 0) return self;
    NSMutableString *string = [NSMutableString string];
    NSArray *cmps = [self componentsSeparatedByString:@"_"];
    for (NSUInteger i = 0; i < cmps.count; i++) {
    NSString *cmp = cmps[i];
    if (i && cmp.length) {
    [string appendString:[NSString stringWithFormat:@"%c", [cmp characterAtIndex:0]].uppercaseString];
    if (cmp.length >= 2) [string appendString:[cmp substringFromIndex:1]];
    } else {
    [string appendString:cmp];
    }
    }
    return string;
    }

from esjsonformat-xcode.

windfringe avatar windfringe commented on September 10, 2024

建议作者把这种转换作为可选项吧,有时候不一定希望把下划线替换成驼峰的 :)

from esjsonformat-xcode.

Related Issues (20)

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.