def to_json(cls, config, compact=False, indent=2, level=0):
        """Convert HOCON input into a JSON output

        :return: JSON string representation
        :type return: basestring
        """
        lines = ""
        if isinstance(config, ConfigTree):
            if len(config) == 0:
                lines += '{}'
            else:
                lines += '{\n'
                bet_lines = []
                for key, item in config.items():
                    bet_lines.append('{indent}"{key}": {value}'.format(
                        indent=''.rjust((level + 1) * indent, ' '),
                        key=key.strip('"'),  # for dotted keys enclosed with "" to not be interpreted as nested key
                        value=cls.to_json(item, compact, indent, level + 1))
                    )
                lines += ',\n'.join(bet_lines)
                lines += '\n{indent}}}'.format(indent=''.rjust(level * indent, ' '))
        elif isinstance(config, list):
            if len(config) == 0:
                lines += '[]'
            else:
                lines += '[\n'
                bet_lines = []
                for item in config:
                    bet_lines.append('{indent}{value}'.format(
                        indent=''.rjust((level + 1) * indent, ' '),
                        value=cls.to_json(item, compact, indent, level + 1))
                    )
                lines += ',\n'.join(bet_lines)
                lines += '\n{indent}]'.format(indent=''.rjust(level * indent, ' '))
        elif isinstance(config, basestring):
            lines = json.dumps(config)
        elif config is None or isinstance(config, NoneValue):
            lines = 'null'
        elif config is True:
            lines = 'true'
        elif config is False:
            lines = 'false'
        else:
            lines = str(config)
        return lines
def to_json ( cls , config , compact = False , indent = 2 , level = 0 ) : lines = "" if isinstance ( config , ConfigTree ) : if len ( config ) == 0 : lines += '{}' else : lines += '{\n' bet_lines = [ ] for key , item in config . items ( ) : bet_lines . append ( '{indent}"{key}": {value}' . format ( indent = '' . rjust ( ( level + 1 ) * indent , ' ' ) , key = key . strip ( '"' ) , value = cls . to_json ( item , compact , indent , level + 1 ) ) ) lines += ',\n' . join ( bet_lines ) lines += '\n{indent}}}' . format ( indent = '' . rjust ( level * indent , ' ' ) ) elif isinstance ( config , list ) : if len ( config ) == 0 : lines += '[]' else : lines += '[\n' bet_lines = [ ] for item in config : bet_lines . append ( '{indent}{value}' . format ( indent = '' . rjust ( ( level + 1 ) * indent , ' ' ) , value = cls . to_json ( item , compact , indent , level + 1 ) ) ) lines += ',\n' . join ( bet_lines ) lines += '\n{indent}]' . format ( indent = '' . rjust ( level * indent , ' ' ) ) elif isinstance ( config , basestring ) : lines = json . dumps ( config ) elif config is None or isinstance ( config , NoneValue ) : lines = 'null' elif config is True : lines = 'true' elif config is False : lines = 'false' else : lines = str ( config ) return lines
Convert HOCON input into a JSON output

        :return: JSON string representation
        :type return: basestring