Apply a transformation function `func` to a value under the specified `path` in the `obj` dictionary.
(obj, path, func)
| 142 | |
| 143 | @staticmethod |
| 144 | def transform_field(obj, path, func): |
| 145 | """ |
| 146 | Apply a transformation function `func` to a value |
| 147 | under the specified `path` in the `obj` dictionary. |
| 148 | """ |
| 149 | for key in path[:-1]: |
| 150 | if not (key in obj and obj[key]): |
| 151 | return |
| 152 | obj = obj[key] |
| 153 | if path[-1] in obj and obj[path[-1]]: |
| 154 | obj[path[-1]] = func(obj[path[-1]]) |
| 155 | |
| 156 | @classmethod |
| 157 | def convert_to_strings(cls, obj): |