JSON命名约定(snake_case,camelCase或PascalCase) [英] JSON Naming Convention (snake_case, camelCase or PascalCase)

查看:410
本文介绍了JSON命名约定(snake_case,camelCase或PascalCase)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在JSON命名的标准?
我看到大多数示例都使用所有小写字母,并用下划线(也称为snake_case)分隔,但也可以使用PascalCasecamelCase吗?

Is there a standard on JSON naming?
I see most examples using all lower case separated by underscore, aka snake_case, but can it be used PascalCase or camelCase as well?

推荐答案

没有单一标准,但我看到了您提到的3种样式("Pascal/Microsoft","Java"(camelCase)和"C") (下划线snake_case)),以及至少一个像longer-name这样的kebab-case).

There is no SINGLE standard, but I have seen 3 styles you mention ("Pascal/Microsoft", "Java" (camelCase) and "C" (underscores, snake_case)) -- as well as at least one more, kebab-case like longer-name).

这似乎主要取决于相关服务的背景开发人员拥有什么;具有c/c ++背景的人(或采用类似命名的语言,包括许多脚本语言,ruby等)通常选择下划线变体;和其余的类似(Java与.NET).例如,提到的Jackson库假定使用Java bean命名约定(camelCase)

It mostly seems to depend on what background developers of the service in question had; those with c/c++ background (or languages that adopt similar naming, which includes many scripting languages, ruby etc) often choose underscore variant; and rest similarly (Java vs .NET). Jackson library that was mentioned, for example, assumes Java bean naming convention (camelCase)

更新:我对标准"的定义是一个单一约定.因此,尽管可以说是的,但有很多标准",但对我来说,有多个Naming Conventions,但整体上都不是"The"标准.其中之一可以被视为特定平台的标准,但是考虑到JSON用于平台之间的互操作性,可能有意义也可能没有意义.

UPDATE: my definition of "standard" is a SINGLE convention. So while one could claim "yes, there are many standards", to me there are multiple Naming Conventions, none of which is "The" standard overall. One of them could be considered the standard for specific platform, but given that JSON is used for interoperability between platforms that may or may not make much sense.

这篇关于JSON命名约定(snake_case,camelCase或PascalCase)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆