def write_json(self, fh, pretty=True):
sjson = json.JSONEncoder().encode(self.json())<EOL>if pretty:<EOL><INDENT>json.dump(json.loads(sjson), fh, sort_keys=True, indent=<NUM_LIT:4>)<EOL><DEDENT>else:<EOL><INDENT>json.dump(json.loads(sjson), fh)<EOL><DEDENT>return<EOL>
Write composite object to file handle in JSON format.

Args:
    fh (file): File handle to write to.
    pretty (bool): Sort keys and indent in output.