JSON命名约定 [英] JSON Naming Convention

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

问题描述

JSON命名是否有标准?我看到大多数示例都使用下划线(lower_case)分隔的所有小写字母.但是,您可以使用PascalCase或camelCase吗?

Is there a standard on JSON naming? I see most examples using all lower case separated by underscore (lower_case). But, can you use PascalCase or camelCase?

推荐答案

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

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命名约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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