JSON中 $ref 的用法
It is a keyword you can use to refer and reuse schemas.
是用来引用,重复使用schema 。
Schema:
{"type": "object",
"title": "A Non-empty linked list",
"required": ["value", "next"],
"properties": {
"value":{"type": "integer"},
"next": {"oneOf":[{"type": "null"},
{"$ref": "#"}]}}}
#是指scheme本身。
有效的输入可以是
{“value”: 1, “next”: {“value”:2, “next”: null}}
可以看出来,next 在one of 中如果选择的是 {"$ref": “#”}]}}}
那么就是指的是schema,所以{“value”: 1, “next”: {“value”:2, “next”: null}} 是正确的。
==========================
{ “$ref”: “#/definitions/address” }
$ref是URI引用,#符号后的部分(“片段”或“命名锚点”)采用称为JSON指针的格式。
$ref值以井号(#)开头。之后,以斜杠分隔的项目遍历文档中对象中的键
收藏:
https://www.postgresql.org/docs/12/functions-json.html
https://json-schema.org/understanding-json-schema/structuring.html