<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def getstruct(self, msgid, as_json=False, stream=sys.stdout):
 """Get and print the whole message. as_json indicates whether to print the part list as JSON or not. """

        parts = [part.get_content_type() for hdr, part in self._get(msgid)]
        if as_json:
            print(json.dumps(parts), file=stream)
        else:
            for c in parts:
                print(c, file=stream)