Skip to content
Snippets Groups Projects
Commit 4bbdf917 authored by Shayan Hajipour's avatar Shayan Hajipour
Browse files

bug fix: json_to_list function bug when json_str is empty list resolved.

parent ccdf13d9
No related branches found
No related tags found
2 merge requests!294Release TeraFlowSDN 4.0,!196Resolve "(CTTC) Incorrect endpoint lookup in NBI ETSI BWM plugin"
......@@ -45,10 +45,12 @@ def json_to_list(json_str : str) -> List[Union[str, Tuple[str, str]]]:
data = json.loads(json_str)
except: # pylint: disable=bare-except
return [('item', str(json_str))]
if isinstance(data, dict):
return [('kv', (key, value)) for key, value in data.items()]
elif isinstance(data, list) and not isinstance(data[0], dict):
elif isinstance(data, list) and len(data) == 1 and isinstance(data[0], dict): # BWM use-case
return [('kv', (key, value)) for key, value in data[0].items()]
elif isinstance(data, list) and all(isinstance(d, str) for d in data):
return [('item', ', '.join(data))]
else:
return [('item', str(data))]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment