def json(
        self,
        filepath=None
    ):
        """*Render the data in json format*

        **Key Arguments:**
            - ``filepath`` -- path to the file to write the json content to. Default *None*

        **Return:**
            - ``renderedData`` -- the data rendered as json

        **Usage:**

            To render the data set as json:

            .. code-block:: python

                print dataSet.json()

            .. code-block:: json

                [
                    {
                        "address": "belfast, uk",
                        "owner": "daisy",
                        "pet": "dog"
                    },
                    {
                        "address": "the moon",
                        "owner": "john",
                        "pet": "snake"
                    },
                    {
                        "address": "larne",
                        "owner": "susan",
                        "pet": "crocodile"
                    }
                ]

            and to save the json rendering to file:

            .. code-block:: python

                dataSet.json("/path/to/myfile.json")
        """
        self.log.debug('starting the ``json`` method')

        dataCopy = copy.deepcopy(self.listOfDictionaries)
        for d in dataCopy:
            for k, v in d.iteritems():
                if isinstance(v,  datetime):
                    d[k] = v.strftime("%Y%m%dt%H%M%S")

        renderedData = json.dumps(
            dataCopy,
            separators=(',', ': '),
            sort_keys=True,
            indent=4
        )

        if filepath and len(self.listOfDictionaries):

            # RECURSIVELY CREATE MISSING DIRECTORIES
            if not os.path.exists(os.path.dirname(filepath)):
                os.makedirs(os.path.dirname(filepath))

            writeFile = codecs.open(filepath, encoding='utf-8', mode='w')
            writeFile.write(renderedData)
            writeFile.close()

        self.log.debug('completed the ``json`` method')
        return renderedData
def json ( self , filepath = None ) : self . log . debug ( 'starting the ``json`` method' ) dataCopy = copy . deepcopy ( self . listOfDictionaries ) for d in dataCopy : for k , v in d . iteritems ( ) : if isinstance ( v , datetime ) : d [ k ] = v . strftime ( "%Y%m%dt%H%M%S" ) renderedData = json . dumps ( dataCopy , separators = ( ',' , ': ' ) , sort_keys = True , indent = 4 ) if filepath and len ( self . listOfDictionaries ) : if not os . path . exists ( os . path . dirname ( filepath ) ) : os . makedirs ( os . path . dirname ( filepath ) ) writeFile = codecs . open ( filepath , encoding = 'utf-8' , mode = 'w' ) writeFile . write ( renderedData ) writeFile . close ( ) self . log . debug ( 'completed the ``json`` method' ) return renderedData
*Render the data in json format*

        **Key Arguments:**
            - ``filepath`` -- path to the file to write the json content to. Default *None*

        **Return:**
            - ``renderedData`` -- the data rendered as json

        **Usage:**

            To render the data set as json:

            .. code-block:: python

                print dataSet.json()

            .. code-block:: json

                [
                    {
                        "address": "belfast, uk",
                        "owner": "daisy",
                        "pet": "dog"
                    },
                    {
                        "address": "the moon",
                        "owner": "john",
                        "pet": "snake"
                    },
                    {
                        "address": "larne",
                        "owner": "susan",
                        "pet": "crocodile"
                    }
                ]

            and to save the json rendering to file:

            .. code-block:: python

                dataSet.json("/path/to/myfile.json")