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

Parse removes newline for comment if it last entry in entity #54

Open
bdruzhynin opened this issue May 11, 2021 · 0 comments
Open

Parse removes newline for comment if it last entry in entity #54

bdruzhynin opened this issue May 11, 2021 · 0 comments

Comments

@bdruzhynin
Copy link

bdruzhynin commented May 11, 2021

I have faced strange behavior of comment processing if it is last entry in object

let parsed = hjson.rt.parse("{\n  a:1/n    // comment 1/n. b: 2\n  //comment 2\n}");
hjson.rt.stringify(parsed) // "{\n  a:1/n    // comment 1/n. b: 2  //comment 2\n}"

Notice that \n disappeared before //comment 2;
As use case it means that if user commented last property of object, after parse/stringify methods, commented property will jump to the previous line
So this object

{
    a:1
    // b:2
}

after parse/stringify methods will become this

{
    a:1 // b:2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant