'Load and then dump the result using parse_constant kwarg
Note that setting invalid separators will cause a failure at this step.'

def encode(self, o):

    encoded_o = super(PlotlyJSONEncoder, self).encode(o)
    try:
        new_o = _json.loads(encoded_o, parse_constant=self.coerce_to_strict)
    except ValueError:
        raise ValueError('Encoding    into    strict    JSON    failed.    Did    you    set    the    separators    valid    JSON    separators?')
    else:
        return _json.dumps(new_o, sort_keys=self.sort_keys, indent=self.indent, separators=(self.item_separator, self.key_separator))
