Skip to content

Commit

Permalink
WIP: Add ProtoHelper::to_json to dump lists of messages or any other …
Browse files Browse the repository at this point in the history
…type (non-recursive)
  • Loading branch information
Grennith committed Jan 15, 2024
1 parent 4aa8ae2 commit 2a7746d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mapadroid/mitm_receiver/protos/ProtoHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ def to_json(value: Union[Message, List[Message], MutableSequence]) -> str:
if isinstance(value, Message):
return MessageToJson(value)
elif isinstance(value, list) or isinstance(value, MutableSequence):
listed: List[Dict] = []
[listed.append(MessageToDict(message)) for message in value]
listed: List[Any] = []
[listed.append(MessageToDict(entry)) if isinstance(entry, Message) else listed.append(entry)
for entry in value]
return json.dumps(listed)
else:
raise ValueError("Cannot convert passed value")

0 comments on commit 2a7746d

Please sign in to comment.