diff --git a/insights/core/__init__.py b/insights/core/__init__.py index 32a264f178..babc6d76bb 100644 --- a/insights/core/__init__.py +++ b/insights/core/__init__.py @@ -748,7 +748,12 @@ class JSONParser(Parser, LegacyItemAccess): """ def parse_content(self, content): try: - self.data = json.loads(''.join(content)) + if isinstance(content, list): + self.data = json.loads('\n'.join(content)) + else: + self.data = json.loads(content) + if self.data is None: + raise SkipException("There is no data") except: # If content is empty then raise a skip exception instead of a parse exception. if not content: diff --git a/insights/parsers/tests/test_tags.py b/insights/parsers/tests/test_tags.py index 79efa9485f..33af8e5688 100644 --- a/insights/parsers/tests/test_tags.py +++ b/insights/parsers/tests/test_tags.py @@ -17,5 +17,16 @@ def test_tags_json(): assert result.data['group'] == "app-db-01" +def test_tags_json_bytes(): + bytes_content = bytes(str(tags_json_content).encode("utf-8")) + ctx = context_wrap(bytes_content) + ctx.content = bytes_content + result = Tags(ctx) + assert result.data['zone'] == "east" + assert result.data['owner'] == "test" + assert result.data['exclude'] == "true" + assert result.data['group'] == "app-db-01" + + def test_tags_empty(): assert 'Empty output.' in skip_exception_check(Tags)