<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_json(self):
 """ Serialises a HucitAuthor to a JSON formatted string. Example: >> homer = kb.get_resource_by_urn("urn:cts:greekLit:tlg0012") >> homer.to_json() { "name_abbreviations": [ "Hom." ], "urn": "urn:cts:greekLit:tlg0012", "works": [ { "urn": "urn:cts:greekLit:tlg0012.tlg001", "titles": [ { "language": "it", "label": "Iliade" }, { "language": "la", "label": "Ilias" }, { "language": "en", "label": "Iliad" }, { "language": "de", "label": "Ilias" }, { "language": "fr", "label": "L'Iliade" } ], "uri": "http://purl.org/hucit/kb/works/2815", "title_abbreviations": [ "Il." ] }, { "urn": "urn:cts:greekLit:tlg0012.tlg002", "titles": [ { "language": "en", "label": "Odyssey" }, { "language": "fr", "label": "L'Odyss\u00e9e" }, { "language": "it", "label": "Odissea" }, { "language": "la", "label": "Odyssea" }, { "language": "de", "label": "Odyssee" } ], "uri": "http://purl.org/hucit/kb/works/2816", "title_abbreviations": [ "Od." ] }, { "urn": "urn:cts:cwkb:927.2814", "titles": [ { "language": "la", "label": "Epigrammata" } ], "uri": "http://purl.org/hucit/kb/works/2814", "title_abbreviations": [ "Epigr." ] } ], "uri": "http://purl.org/hucit/kb/authors/927", "names": [ { "language": "fr", "label": "Hom\u00e8re" }, { "language": "la", "label": "Homerus" }, { "language": null, "label": "Homeros" }, { "language": "en", "label": "Homer" }, { "language": "it", "label": "Omero" } ] } """

        names = self.get_names()
        return json.dumps({
                    "uri" : self.subject
                    , "urn" : str(self.get_urn())
                    , "names" : [{"language":lang, "label":label} for lang, label in names]
                    , "name_abbreviations" : self.get_abbreviations()
                    , "works" : [json.loads(work.to_json()) for work in self.get_works()]
                }, indent=2)