-
Notifications
You must be signed in to change notification settings - Fork 343
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
Ask a question
Hello! I'm trying to marshal a structure containing random key string and float value like this:
{'key_1': 12.5, 'key_2': 42.5, 'key_2': 68.1}
But I have an error: "float() argument must be a string or a number, not 'NoneType' "
The question: Is it not allowable to marshal such a structure or it's an issue?
Additional context
I'm using python v.3.7 and flask-restx v.0.2.0
The code I'm trying to run:
from flask_restx import fields, marshal
wild = fields.Wildcard(fields.Float)
wildcard_fields ={'*': wild}
data = {'John': 12.1, 'bob': 42.2, 'Jane': 68.01}
json.dumps(marshal(data, wildcard_fields))
The error is:
TypeError Traceback (most recent call last)
<ipython-input-324-7d964210af16> in <module>
----> 1 json.dumps(marshal(data, wildcard_fields))
.../lib/python3.7/site-packages/flask_restx/marshalling.py in marshal(data, fields, envelope, skip_none, mask, ordered)
90 value = field.output(dkey, data, ordered=ordered)
91 if value is None or value == field.container.format(
---> 92 field.default
93 ):
94 break
.../lib/python3.7/site-packages/flask_restx/fields.py in format(self, value)
473 def format(self, value):
474 try:
--> 475 return float(value)
476 except ValueError as ve:
477 raise MarshallingError(ve)
TypeError: float() argument must be a string or a number, not 'NoneType'
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested