On Tue, Jul 16, 2013 at 01:08:55PM +0200, Paolo Bonzini wrote: > Il 16/07/2013 13:04, Amos Kong ha scritto: > >>> > > So here I defined a 'DataObject' type in qapi-schema.json, > >>> > > it's used to describe the dynamical dictionary/list/string. > >>> > > > >>> > > { 'type': 'DataObject', > >>> > > 'data': { '*key': 'str', '*type': 'str', '*data': ['DataObject'] } } > > > > Hi Paolo, > > > >> > This is missing '*optional': 'bool'. Also, how do you distinguish these: > >> > > >> > { 'command': 'query-tpm-types', 'returns': 'TpmType] } > > do you mean 'TpmType' ? not 'TpmType] > > Yes. > > > { > > "name": "query-tpm-types", > > "type": "Command", > > "returns": [ > > > { > > > "type": "passthrough" > > > } > > ] > > }, > > > >> > { 'command': 'query-tpm-types', 'returns': ['TpmType'] } > > { > > "name": "query-tpm-types", > > "type": "Command", > > "returns": [ > > > { > > > "type": "TpmType", > > > "data": [ > > > { > > > "type": "passthrough" > > > } > > > ] > > > } > > ] > > }, > > Thanks. I see this is unique, but it is also not too intuitive. > > So, could you add a "kind" field to DataObject that is an enum > (list/dict/scalar, or something like that)? This would make it easier > to parse (for humans at least, but I guess also for programs).
I thought we can identify the kind by some judgment. if the dict has key 'key', it's a dict if no 'key', have 'type', it's a list if only have 'type', it's a buildin type (or extended type that doesn't need to be extended) if no 'key', have 'type' & 'data', it's extended list type if have 'key', 'type', 'data', it's extended dict type I will added a 'kind' field to make it clearer. KIND enum: list dict str scalar(bool): Or just simplely check if have 'data' key? true/false Amos > Paolo