def format_json(self, path_tree, **kwargs):
    d = OrderedDict()
    for key in self.normalize_fields(path_tree):
        key_val = try_key(key, self)
        if hasattr(key_val, 'format_json'):
            sub_tree = path_tree.get(key, {})
            d[key] = key_val.format_json(sub_tree, **kwargs)
        else:
            d[key] = key_val
    return d
def format_json(self, path_tree, **kwargs):
    d = OrderedDict()
    for key in self.normalize_fields(path_tree):
        key_val = try_key(key, self)
        if hasattr(key_val, 'format_json'):
            sub_tree = path_tree.get(key, {})
            d[key] = key_val.format_json(sub_tree, **kwargs)
        else:
            d[key] = key_val
    return d