Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid json being generated with wrap_line_length #1932

Closed
jseward opened this issue May 8, 2021 · 0 comments · Fixed by #2116
Closed

invalid json being generated with wrap_line_length #1932

jseward opened this issue May 8, 2021 · 0 comments · Fixed by #2116

Comments

@jseward
Copy link

jseward commented May 8, 2021

Description

invalid json being generated with wrap_line_length where the "-" character and numeric characters are split between multiple lines.

Input

The code looked like this before beautification:

{
            "1234567891234567891234567891234": -4
}

Expected Output

The code should have looked like this after beautification:

{
            "1234567891234567891234567891234": -4
}

Actual Output

The code actually looked like this after beautification:

{
            "1234567891234567891234567891234": -
            4
}

Steps to Reproduce

        options = jsbeautifier.default_options()
        options.indent_size = 4
        options.brace_style = "expand"
        options.wrap_line_length = 40
        obj = {
            "1234567891234567891234567891234": -4
        }
        json.loads(jsbeautifier.beautify(json.dumps(obj), options))
mhnaeem added a commit to mhnaeem/js-beautify that referenced this issue Nov 17, 2022
This fix makes sure we can identify signed numbers correctly when they are used as an object property to avoid having issues with line wrapping

fixes beautifier#1932
@bitwiseman bitwiseman added this to the v1.14.10 (next release) milestone Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants