Example #1
0
    def parse_region(self, edit, region):
        content = self.view.substr(region)

        try:
            json_data = parse_input(content)
        except Exception as e:
            logger.error(e, exc_info=True)
        else:
            output = format_output(json_data,
                                   indent=self.view.settings().get(
                                       "tab_size", 2),
                                   separators=(",", ": "),
                                   sort_keys=settings.get("sort_keys") is True,
                                   ensure_ascii=False)
            self.view.replace(edit, region, output)
    def parse_region(self, edit, region):
        content = self.view.substr(region)

        try:
            json_data = parse_input(content)
        except Exception as e:
            logger.error(e, exc_info=True)
        else:
            output = format_output(
                json_data,
                indent=self.view.settings().get("tab_size", 2),
                separators=(",", ": "),
                sort_keys=settings.get("sort_keys") is True,
                ensure_ascii=False,
            )
            self.view.replace(edit, region, output)
def test_fail_yaml():
    data = parse_input(get_static_content("fail_yaml/test.json"))
    output = format_output(data)
    assert json.loads(output) == json.loads(get_static_content("fail_yaml/result.json"))
def test_no_collections():
    data = parse_input(get_static_content("base/test.json"), use_collections=False)
    output = format_output(data)
    assert json.loads(output) == json.loads(get_static_content("base/result.json"))
def test_indent():
    data = parse_input(get_static_content("indent/test.json"))
    output = format_output(data, indent=4)
    assert output == get_static_content("indent/result.json")
Example #6
0
def test_fail_yaml():
    data = parse_input(get_static_content('fail_yaml/test.json'))
    output = format_output(data)
    assert json.loads(output) == json.loads(
        get_static_content('fail_yaml/result.json'))
Example #7
0
def test_no_collections():
    data = parse_input(get_static_content('base/test.json'),
                       use_collections=False)
    output = format_output(data)
    assert json.loads(output) == json.loads(
        get_static_content('base/result.json'))
Example #8
0
def test_indent():
    data = parse_input(get_static_content('indent/test.json'))
    output = format_output(data, indent=4)
    assert output == get_static_content('indent/result.json')
Example #9
0
def assert_static_test(static_test, value=True):
    data = parse_input(get_static_content('%s/test.json' % static_test))
    output = format_output(data)
    assert (output == get_static_content('%s/result.json' % static_test)) == value
Example #10
0
def assert_static_test(static_test, value=True):
    data = parse_input(get_static_content('%s/test.json' % static_test))
    output = format_output(data)
    assert (output == get_static_content('%s/result.json' %
                                         static_test)) == value