From 17f875041d566f21a1eb03d609fd880cdf53e416 Mon Sep 17 00:00:00 2001 From: lavanyagarg112 Date: Thu, 26 Sep 2024 12:16:01 +0800 Subject: [PATCH] modify process_body function to correctly access the nested keys --- httpie/output/streams.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/httpie/output/streams.py b/httpie/output/streams.py index 16491bcb..a20b6b77 100644 --- a/httpie/output/streams.py +++ b/httpie/output/streams.py @@ -273,8 +273,18 @@ class FilterStream(EncodedStream): chunk = self.decode_chunk(chunk) chunk_dict = eval(chunk) for word in self.filters: - if word in chunk_dict: - del chunk_dict[word] + temp_dict = chunk_dict + splitwords = word.split(".") + for i in range(len(splitwords)-1): + subword = splitwords[i] + if subword in temp_dict: + temp_dict = temp_dict[subword] + else: + break + else: + subword = splitwords[-1] + if subword in temp_dict: + del temp_dict[subword] chunk = f'{chunk_dict}' return smart_encode(chunk, self.output_encoding) @@ -308,9 +318,10 @@ class PrettyFilterStream(PrettyStream): temp_dict = temp_dict[subword] else: break - subword = splitwords[-1] - if subword in temp_dict: - del temp_dict[subword] + else: + subword = splitwords[-1] + if subword in temp_dict: + del temp_dict[subword] chunk = (f'{chunk_dict}').replace(" ", "").replace("'", '"') chunk = self.formatting.format_body(content=chunk, mime=self.mime) return smart_encode(chunk, self.output_encoding)