From 2a7746d96c34f8f1097fe98498b674ab6d5fac88 Mon Sep 17 00:00:00 2001 From: Till Skrodzki Date: Mon, 15 Jan 2024 20:23:38 +0100 Subject: [PATCH] WIP: Add ProtoHelper::to_json to dump lists of messages or any other type (non-recursive) --- mapadroid/mitm_receiver/protos/ProtoHelper.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mapadroid/mitm_receiver/protos/ProtoHelper.py b/mapadroid/mitm_receiver/protos/ProtoHelper.py index 1fe178765..6863f3d86 100644 --- a/mapadroid/mitm_receiver/protos/ProtoHelper.py +++ b/mapadroid/mitm_receiver/protos/ProtoHelper.py @@ -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")