gpt4 book ai didi

json-api - 如何在 JSON :API? 中编写两个字类型

转载 作者:行者123 更新时间:2023-12-02 03:18:54 25 4
gpt4 key购买 nike

我想将外星文物发布到我的服务器。

我应该写 type="alienArtifact"

或 type="alien-artifact"

或者完全不同的东西?

我看这里https://jsonapi.org/format/但仅处理简单类型“对象”。

最佳答案

如果您使用 kebab-casesnake_casecamelCase 作为字段名称,则 JSON:API 规范是不可知的,但它带有 recommendation :

Member names SHOULD be camel-cased (i.e., wordWordWord)

此建议于 2018 年 10 月更改。之前是 kebab-case。因此,许多有关 JSON:API 规范和库文档的文章仍在使用 kebab-case。这些论点是这一变化的主要原因:

  • camelCased names can be used directly as identifiers in almost all programming languages, making json:api easier to get started with and to work with over time. Dasherized names are usable as identifiers pretty much only in Lisps.

  • camelCased names are the most common convention in the JS community, and JS is the biggest user of JSON:API

  • camelCased names are slightly shorter than dasherized (or snake-case) names, which could help with url character limits in the case of complex filters or other types of complex queries (e.g., some GraphQL like “deep querying” feature) that we might serialize into urls in the future.

您可以在 appropriate pull request 中找到有关此更改的更多详细信息。

关于json-api - 如何在 JSON :API? 中编写两个字类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55393855/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com