*Render the results in json format*

        **Key Arguments:**
            - ``dirPath`` -- the path to the directory to save the rendered results to. Default *None*

        **Return:**
            - `jsonSources` -- the top-level transient data
            - `jsonPhot` -- all photometry associated with the transients
            - `jsonSpec` -- all spectral data associated with the transients
            - `jsonFiles`  -- all files associated with the matched transients found on the tns

        **Usage:**

            To render the results in json format:

            .. code-block:: python

                jsonSources, jsonPhot, jsonSpec, jsonFiles  = tns.json()
                print jsonSources

            .. code-block:: text

                [
                    {
                        "TNSId": "2016asf",
                        "TNSName": "SN2016asf",
                        "decDeg": 31.1126,
                        "decSex": "+31:06:45.36",
                        "discDate": "2016-03-06 08:09:36",
                        "discMag": "17.1",
                        "discMagFilter": "V-Johnson",
                        "discSurvey": "ASAS-SN",
                        "discoveryName": "ASASSN-16cs",
                        "hostName": "KUG 0647+311",
                        "hostRedshift": null,
                        "objectUrl": "http://wis-tns.weizmann.ac.il/object/2016asf",
                        "raDeg": 102.65304166666667,
                        "raSex": "06:50:36.73",
                        "separationArcsec": "0.66",
                        "separationEastArcsec": "-0.13",
                        "separationNorthArcsec": "0.65",
                        "specType": "SN Ia",
                        "transRedshift": "0.021"
                    }
                ]

            You can save the results to file by passing in a directory path within which to save the files to. The four flavours of data (sources, photometry, spectra and files) are saved to separate files but all data can be assoicated with its transient source using the transient's unique `TNSId`.

            .. code-block:: python

                tns.json("~/tns")

            .. image:: https://i.imgur.com/wAHqARI.png
                :width: 800px
                :alt: json output

def json(
            self,
            dirPath=None):
        """*Render the results in json format*

        **Key Arguments:**
            - ``dirPath`` -- the path to the directory to save the rendered results to. Default *None*

        **Return:**
            - `jsonSources` -- the top-level transient data
            - `jsonPhot` -- all photometry associated with the transients
            - `jsonSpec` -- all spectral data associated with the transients
            - `jsonFiles`  -- all files associated with the matched transients found on the tns

        **Usage:**

            To render the results in json format:

            .. code-block:: python

                jsonSources, jsonPhot, jsonSpec, jsonFiles  = tns.json()
                print jsonSources

            .. code-block:: text

                [
                    {
                        "TNSId": "2016asf",
                        "TNSName": "SN2016asf",
                        "decDeg": 31.1126,
                        "decSex": "+31:06:45.36",
                        "discDate": "2016-03-06 08:09:36",
                        "discMag": "17.1",
                        "discMagFilter": "V-Johnson",
                        "discSurvey": "ASAS-SN",
                        "discoveryName": "ASASSN-16cs",
                        "hostName": "KUG 0647+311",
                        "hostRedshift": null,
                        "objectUrl": "http://wis-tns.weizmann.ac.il/object/2016asf",
                        "raDeg": 102.65304166666667,
                        "raSex": "06:50:36.73",
                        "separationArcsec": "0.66",
                        "separationEastArcsec": "-0.13",
                        "separationNorthArcsec": "0.65",
                        "specType": "SN Ia",
                        "transRedshift": "0.021"
                    }
                ]

            You can save the results to file by passing in a directory path within which to save the files to. The four flavours of data (sources, photometry, spectra and files) are saved to separate files but all data can be assoicated with its transient source using the transient's unique `TNSId`.

            .. code-block:: python

                tns.json("~/tns")

            .. image:: https://i.imgur.com/wAHqARI.png
                :width: 800px
                :alt: json output
        """

        if dirPath:
            p = self._file_prefix()
            jsonSources = self.sourceResults.json(
                filepath=dirPath + "/" + p + "sources.json")
            jsonPhot = self.photResults.json(
                filepath=dirPath + "/" + p + "phot.json")
            jsonSpec = self.specResults.json(
                filepath=dirPath + "/" + p + "spec.json")
            jsonFiles = self.relatedFilesResults.json(
                filepath=dirPath + "/" + p + "relatedFiles.json")
        else:
            jsonSources = self.sourceResults.json()
            jsonPhot = self.photResults.json()
            jsonSpec = self.specResults.json()
            jsonFiles = self.relatedFilesResults.json()
        return jsonSources, jsonPhot, jsonSpec, jsonFiles