clean_dict

The clean_dict is a small recursive function that given a dictionary will try to ‘clean it’ converting it to a string:

clean_dict(dictionary)

It is commonly used in conjunction with the log_json function.

Example

snippet taken from zun_self.py:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
 def dispatch(self, request, response):

     return (
         json.dumps(
             tools.clean_dict(request.__dict__),
             sort_keys=True,
             indent=4)
     )
     # taking advantage of the tools.log_json
     # return tools.log_json(request.__dict__, 4)

Many thanks Paw - The ultimate REST client for Mac. for supporting Open Source projects.

paw

A great amount of time has been spent creating, crafting and maintaining this software, please consider donating.

Donating helps ensure continued support, development and availability.

dalmp


comments powered by Disqus