def to_json_string()

in AWSIoTDeviceDefenderAgentSDK/metrics.py [0:0]


    def to_json_string(self, pretty_print=False):
        """
        Convert the metrics to a json string suitable for AWS IoT Device Defender.

        Parameters
        ----------
        pretty_print: bool
            Set to true if you would like json to be formatted in a more human-friendly format.

        """
        metrics = self._v1_metrics()
        if pretty_print:
            return json.dumps(metrics, indent=4, sort_keys=True)
        else:
            return json.dumps(metrics, separators=(',', ':'))