我有一个json:
{ "itemType": {"food":22,"electrical":2},"itemCount":{"NA":211} }
这里的itemType和itemCount将是常见的,但不是它们内部的值(食物,NA,电子),它们将不断变化,但将采用以下格式:地图
如何为这种通用结构定义Json Schema?
我试过了 :
"itemCount":{ "type": "object" "additionalProperties": {"string","integer"} }
解决方法
您可以:
{ "type": "object","properties": { "itemType": {"$ref": "#/definitions/mapInt"},"itemCount": {"$ref": "#/definitions/mapInt"} },"definitions": { "mapInt": { "type": "object","additionalProperties": {"type": "integer"} } } }