Skip to content

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

@bdruzhynin

Description

@bdruzhynin

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions