Hello,
Le 05/12/2013 17:55, Michał Dulko a écrit :
> [...]
>
> How can I achieve custom dictionary in WSME object? The dictionary can
> contain different types of data (float, int, bool, string).
WSME does not support attribute with non-fixed types. That includes
dictionnaries.
So you have to specify what types will your dictionnary will carry, for
example : {str: int} is a dictionnary with string keys and integer
values (see the doc [1] for an example).
If you must have 'variable' type for the values, one way is to define
complex type with one attribute for each potential type :
class ValueHolder(Base):
as_int = int
as_str = str
# and so on
and use it in your dictionnary :
{str: ValueHolder}
Json serialized values would look like :
{"somekey": {"as_int": 5}, "someotherkey": {"as_str": "some text"}}
Cheers,
Christophe
[1]
https://wsme.readthedocs.org/en/latest/types.html#native-types