标签: camelcasing

Doctrine 2 ORM 使用可恶的 CamelCase 创建类

我为 Doctrine 创建了 yaml 配置。当我尝试时doctrine orm:generate-entities,它会创建带有驼峰式大小写的 getter 和 setter 的 php 文件。因此,is_public领域转化为setIsPublic方法getIsPublic。真是太糟糕了。我怎样才能得到set_is_publicget_is_public?我可以手动编辑生成的 php 文件,但我不知道更改架构时会发生什么。

camelcasing getter-setter doctrine-orm

4
推荐指数
1
解决办法
4111
查看次数

NHibernate:为什么field.camelcase?

有人可以告诉我为什么NHibernate映射我们可以设置access="field.camelcase",因为我们有access="field"access="property"

编辑:我的问题是"为什么我们能做到这一点",而不是"它是什么意思".我认为这可能是开发人员的错误来源.

nhibernate camelcasing nhibernate-mapping

4
推荐指数
1
解决办法
1784
查看次数

没有为名称为"成功"的"redirect-action"类型定义结果类型

<action name="saveGetStarted" class="com.sample.action.GetStartedAction" method="save">
      <interceptor-ref name="defaultStack"/>
      <result name="success" type="redirect-action">
          <param name="actionName">preQualification</param>
          <param name="customerId">${customerId}</param>
      </result>
      <result name="input">/jsp/getStarted.jsp</result>
      <result name="error">/jsp/getStarted.jsp</result>
</action>

<action name="preQualification"  class="com.sample.action.PreQualificationAction">
    <result name="success">/jsp/preQualification.jsp</result>
    <result name="input"  >/jsp/preQualification.jsp</result>
</action>
Run Code Online (Sandbox Code Playgroud)

随着struts2-core-2.0.12.jar它工作正常,但在更新后struts2-core-2.1.6.jar,我得到以下错误:

Caused by: There is no result type defined for type 'redirect-action' mapped with name 'success'.  Did you mean 'redirectAction'? - result - file:/D:/eclipse-indigo/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/Fundation/WEB-INF/classes/struts.xml:19:54
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildResults(XmlConfigurationProvider.java:613)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:364)
    ... 26 more
Run Code Online (Sandbox Code Playgroud)

是什么导致错误?

java configuration camelcasing struts2 naming-conventions

4
推荐指数
2
解决办法
4001
查看次数

RestSharp在camelCase中序列化JSON

我想在camelCase中发布JSON,并按照这里的说明操作:

https://github.com/restsharp/RestSharp/wiki/Deserialization#overriding-jsonserializationstrategy

public class CamelCaseSerializerStrategy : PocoJsonSerializerStrategy
{
    protected override string MapClrMemberNameToJsonFieldName(string clrPropertyName)
    {
    return char.ToLower(clrPropertyName[0]) + clrPropertyName.Substring(1);
    }
}
Run Code Online (Sandbox Code Playgroud)

然后我用这段代码创建一个新的客户端:

var client = new RestClient(_baseUrl);
SimpleJson.CurrentJsonSerializerStrategy = new CamelCaseSerializerStrategy();
Run Code Online (Sandbox Code Playgroud)

但是,在发出请求时,串行器未激活.RestSharp文档遍布整个地方,并且大部分都是错误的.查看源代码(RestRequest.AddBody),看起来根本不使用SerializerStrategy.

我一直在寻找一种在客户端级别进行此更改的方法,或者在不需要修改每个请求的地方.

我见过这个博客 - 也许这是唯一的方法.如果您只能在请求级别更改序列化策略,这似乎是RestSharp的一大步.

json camelcasing simplejson restsharp

4
推荐指数
3
解决办法
5753
查看次数

Python:更改大写字母

我无法弄清楚如何在python中替换字符串中的第二个大写字母.

例如:

string = "YannickMorin" 
Run Code Online (Sandbox Code Playgroud)

我希望它成为yannick-morin

到目前为止,我可以通过执行string.lower()来使它全部小写,但是当它找到第二个大写字母时如何设置破折号.

python camelcasing

4
推荐指数
1
解决办法
231
查看次数

常规 rxpression 将驼峰式字符串转换为 kebab 式字符串

function hyphenate(str) {

  var replace = "-";
  str = str.toLowerCase().replace(/[\s_\b]/g, replace);

  console.log(str);
  return str;
}

hyphenate("This Is Hyphenate"); // this-is-hyphenate
hyphenate("camelCaseString");   // camel-case-string
Run Code Online (Sandbox Code Playgroud)

我试图让我的代码生成第二个函数调用的结果,但尚未确定可以执行此操作的模式。任何帮助将不胜感激。

javascript regex camelcasing

4
推荐指数
1
解决办法
2637
查看次数

使用JQ替换JSON中的下划线

我正在使用woocommerce API来检索和存储信息.目前我们的设置旨在使用驼峰案例而不是下划线.我正在使用jq处理我们的信息,但我很好奇如何使用该sub(regex, tostring)函数用camelCase替换我的JSON中的下划线?

这是代码的一个例子

"line_items": [
    {
     "id": xxxx,
     "name": "xxxx",
     "sku": "xxxx",
     "product_id": xxxx,
    }
Run Code Online (Sandbox Code Playgroud)

例如,根据我发现的SO的另一个答案,这可行:curl https://www.testsite.com/wp-json/wc/v1/orders -u user:pass | jq '.[] | with_entries( if .key | contains("_") then .key |= sub("_";"") else . end)'并删除下划线.

结果是:

"lineitems": [
    {
     "id": xxxx,
     "name": "xxxx",
     "sku": "xxxx",
     "productid": xxxx,
    }
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试时,curl https://www.testsite.com/wp-json/wc/v1/orders -u user:pass | jq '.[] | with_entries( if .key | contains("_") then .key |= sub("(\\_)([a-z])";"$2\u") else . end)'我没有得到我期望的结果.

预期结果将是:

"lineItems": …
Run Code Online (Sandbox Code Playgroud)

regex json camelcasing key jq

4
推荐指数
2
解决办法
3735
查看次数

为什么 react wai-aria 不在camelCase 中?

来自反应文档

请注意,JSX 完全支持所有 aria-* HTML 属性。虽然 React 中的大多数 DOM 属性和属性都是驼峰式的,但这些属性应该是连字符(也称为 kebab-case、lisp-case 等),因为它们在纯 HTML 中:

AFAIK,每个 HTML 属性在反应中都被重命名为驼峰命名法。有什么理由可以解释为什么aria-*保留他们原来的名字吗?

奖金,有没有人知道,应该是<input autoFocus='autofocus'/>还是<input autofocus='autofocus'/>。前者看起来是正确的,因为我的编辑器没有发出任何警告。但是属性名和它的值不一致吗?

它也应该是autocompleteautoComplete,而在原始属性名称中auto和之间没有连字符complete

accessibility camelcasing naming-conventions wai-aria reactjs

4
推荐指数
1
解决办法
944
查看次数

将 JSON 驼峰案例转换为蛇案例(反之亦然)并字符串化数值

我必须向 Web REST 服务发送和接收 JSON 对象。这些对象由一个 DLL 生成,该 DLL 将大写字母(“PropertyName”)中的属性名称序列化,并且 Web 服务需要蛇形大小写(“property_name”)。另外,DLL 将数值序列化为浮点数,但 REST API 需要所有字符串。处理对象后,REST 服务返回蛇形大小写 JSON。

JSON 很复杂并且包含嵌套的数组和对象。在从 REST 字符串转换回来时,我可以跳过数字字符串的去字符串化,但我仍然必须将属性名称重新转换为大写字母。

我正在考虑使用 Newtonsoft Json 库编写一个辅助类,但它看起来比我预期的要棘手。转换器应接受 JSON 并返回 JSON。

例子:

{
    "FirstObject": {
        "NestedObject": {
            "AttributeString": "ok",
            "AttributeNumeric": 123.45
        },
        "OtherObject": [{
            "ArrayVal": 100
        }, {
            "ArrayVal": 200
        }]
    }
}
Run Code Online (Sandbox Code Playgroud)

应该成为

{
    "first_object": {
        "nested_object": {
            "attribute_string": "ok",
            "attribute_numeric": "123.45"
        },
        "other_object": [{
            "array_val": "100"
        }, {
            "array_val": "200"
        }]
    }
}
Run Code Online (Sandbox Code Playgroud)

我看到 Json.Net 库有SnakeCaseNamingStrategyCamelCaseNamingStrategy类,所以想法是使用 …

c# json camelcasing json.net

4
推荐指数
1
解决办法
7266
查看次数

Python + Flask REST API,如何在驼峰式和蛇式之间转换数据键?

我正在学习 Python,并使用Flask微框架编写简单的 REST API 。

我使用SQLAlchemy进行对象关系映射,使用Marshmallow进行对象序列化/反序列化。

我的变量名使用蛇形大小写(根据PEP8)。

当从前端(Angular)接收数据时,我需要将 JSON 对象键从驼峰式转换为蛇式,反之亦然,返回响应数据时。

使用 Flask 执行此操作的最佳方法是什么?

我无法在互联网上找到好的答案。

python camelcasing flask snakecasing

4
推荐指数
1
解决办法
2410
查看次数