Skip to content

Commit

Permalink
Return id for objects when flattening cf's
Browse files Browse the repository at this point in the history
  • Loading branch information
Kani999 committed Nov 23, 2022
1 parent 39f8947 commit 75ab3ae
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pynetbox/core/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,21 @@ def get_return(lookup, return_fields=None):


def flatten_custom(custom_dict):
return {k: v for k, v in custom_dict.items()}
ret = {}

for k, val in custom_dict.items():
current_val = val

if isinstance(val, dict):
current_val = val.get('id', val)

if isinstance(val, list):
current_val = [
v.get("id") if isinstance(v, dict) else v for v in val
]

ret[k] = current_val
return ret


class JsonField:
Expand Down

0 comments on commit 75ab3ae

Please sign in to comment.