如何在 ajax 中使用 json api 规范?
How to use json api specs in ajax?
我的数据应该如何以及如何使用 JSON API 规范和 ajax 从端点获取数据。提前致谢
我的数据格式正确吗?
照片link:https://drive.google.com/file/d/1j6At0x3kX3wAQ178IBVG4tOHOMUrpxcw/view?usp=drivesdk
您评论中包含的屏幕截图中显示的数据格式不是有效的 JSON:API 文档。 JSON:API 文档必须遵循 JSON:API specification.
中描述的特定模式
例如,您的屏幕截图中显示的 JSON 验证了规范的此要求:
A document MUST contain at least one of the following top-level members:
data
: the document’s “primary data”
errors
: an array of error objects
meta
: a meta object that contains non-standard meta-information.
此外,表示资源的每个对象都违反了 JSON:API 规范的多项要求,例如:
A resource object MUST contain at least the following top-level members:
- id
- type
[...]
In addition, a resource object MAY contain any of these top-level members:
attributes
: an attributes object representing some of the resource’s data.
relationships
: a relationships object describing relationships between the resource and other JSON:API resources.
links
: a links object containing links related to the resource.
meta
: a meta object containing non-standard meta-information about a resource that can not be represented as an attribute or relationship.
JSON:API 规范包含 well-formed JSON:API 文档的多个示例。我建议看一下它们以更好地理解规范。
我的数据应该如何以及如何使用 JSON API 规范和 ajax 从端点获取数据。提前致谢
我的数据格式正确吗?
照片link:https://drive.google.com/file/d/1j6At0x3kX3wAQ178IBVG4tOHOMUrpxcw/view?usp=drivesdk
您评论中包含的屏幕截图中显示的数据格式不是有效的 JSON:API 文档。 JSON:API 文档必须遵循 JSON:API specification.
中描述的特定模式例如,您的屏幕截图中显示的 JSON 验证了规范的此要求:
A document MUST contain at least one of the following top-level members:
data
: the document’s “primary data”errors
: an array of error objectsmeta
: a meta object that contains non-standard meta-information.
此外,表示资源的每个对象都违反了 JSON:API 规范的多项要求,例如:
A resource object MUST contain at least the following top-level members:
- id
- type
[...]
In addition, a resource object MAY contain any of these top-level members:
attributes
: an attributes object representing some of the resource’s data.relationships
: a relationships object describing relationships between the resource and other JSON:API resources.links
: a links object containing links related to the resource.meta
: a meta object containing non-standard meta-information about a resource that can not be represented as an attribute or relationship.
JSON:API 规范包含 well-formed JSON:API 文档的多个示例。我建议看一下它们以更好地理解规范。