sanitize_for_serialization#
- ApiClient.sanitize_for_serialization(obj)#
Build a JSON POST object.
Based on the object type, this method returns the sanitized JSON representation to send to the server:
If obj is
None, returnNone.If obj is
str,int,floatorbool, return directly.If obj is
datetime.datetimeordatetime.date, convert to string iniso8601format.If obj is
list, sanitize each element in thelist.If obj is
tuple, sanitize each element in thetuple.If obj is
dict, return thedict.If obj is an OpenAPI model, return the
propertiesdict.
- Parameters:
- obj
DeserializedType Data to sanitize and serialize.
- obj
Examples
>>> client = ApiClient(requests.Session(), ... 'http://my-api.com/API/v1.svc', ... SessionConfiguration()) ... client.sanitize_for_serialization({'key': 'value'}) {'key': 'value'}
>>> client = ApiClient(requests.Session(), ... 'http://my-api.com/API/v1.svc', ... SessionConfiguration()) ... client.sanitize_for_serialization(datetime.datetime(2015, 10, 21, 10, 5, 10)) '2015-10-21T10:05:10'