我正在使用 python-json-schema-objects 从模式中自动生成类。我正在尝试用已经生成的对象填充数组。
但我收到了这个错误 -
TypeError 不可散列类型:'rqm__Cell'
我的问题和错误与此处发布的问题非常相似 https://github.com/cwacek/python-jsonschema-objects/issues/126
这是架构
"rqm__RatType": {
"type": "string",
"enum": [
"GSM",
"CDMA"
]
},
"rqm__ChannelBandwidth": {
"type": "string",
"enum": [
"BW_1_4_MHZ",
"BW_3_MHZ",
]
},
"rqm__Cell": {
"type": "object",
"properties": {
"rat": {
"$ref": "#/definitions/rqm__RatType"
},
"bandwidth": {
"$ref": "#/definitions/rqm__ChannelBandwidth"
}
}
},
"rqm__CellSet": {
"type": "object",
"properties": {
"cellsToDeploy": {
"type": "array",
"items": {
"$ref": "#/definitions/rqm__Cell"
},
"minItems": 0,
"uniqueItems": true
}
}
},
我正在使用的代码是
import python_jsonschema_objects as pjs
schema = {}
schema['Rqm'] = 'rqm.json'
builder = pjs.ObjectBuilder(schema['Rqm'])
ns = builder.build_classes()
Cell = ns.RqmCell
CellSet = ns.RqmCellset
cellSet = None
GSMCell = Cell(rat='GSM', bandwidth='BW_1_4_MHZ')
cellSet = CellSet(cellsToDeploy=[GSMCell])
在最后一行我得到这个错误
TypeError 不可散列类型:'rqm__Cell'
非常感谢任何类型的铅