(self, json_entry, column_names=None)
Add an entry that is in a JSON format.

        Args:
            json_entry: a single entry encoded in JSON.
            column_names: a list of column names if the JSON object
                is a list as an opposed to a dict.

        Raises:
            TypeError: if the entry is not JSON or in the wrong JSON format.
Add an entry that is in a JSON format.
Add an entry that is in a JSON format .
def add_json(self, json_entry, column_names=None):
        """Add an entry that is in a JSON format.

        Args:
            json_entry: a single entry encoded in JSON.
            column_names: a list of column names if the JSON object
                is a list as an opposed to a dict.

        Raises:
            TypeError: if the entry is not JSON or in the wrong JSON format.
        """
        try:
            json_obj = json.loads(json_entry)
        except json.JSONDecodeError as e:
            raise TypeError('Data not as JSON, error: {0!s}'.format(e)) from e

        json_dict = {}
        if isinstance(json_obj, (list, tuple)):
            if not column_names:
                raise TypeError(
                    'Data is a list, but there are no defined column names.')
            if not len(json_obj) != len(column_names):
                raise TypeError(
                    'The number of columns ({0:d}) does not match the number '
                    'of columns in the JSON list ({1:d})'.format(
                        len(column_names), len(json_obj)))
            json_dict = dict(zip(column_names, json_obj))
        elif isinstance(json_obj, dict):
            json_dict = json_obj
        else:
            raise TypeError(
                'The JSON object needs to be either a dict or a list with '
                'defined column names.')

        self.add_dict(json_dict)
def add_json ( self , json_entry , column_names = None ) : try : json_obj = json . loads ( json_entry ) except json . JSONDecodeError as e : raise TypeError ( 'Data not as JSON, error: {0!s}' . format ( e ) ) from e json_dict = { } if isinstance ( json_obj , ( list , tuple ) ) : if not column_names : raise TypeError ( 'Data is a list, but there are no defined column names.' ) if not len ( json_obj ) != len ( column_names ) : raise TypeError ( 'The number of columns ({0:d}) does not match the number ' 'of columns in the JSON list ({1:d})' . format ( len ( column_names ) , len ( json_obj ) ) ) json_dict = dict ( zip ( column_names , json_obj ) ) elif isinstance ( json_obj , dict ) : json_dict = json_obj else : raise TypeError ( 'The JSON object needs to be either a dict or a list with ' 'defined column names.' ) self . add_dict ( json_dict )