-
Notifications
You must be signed in to change notification settings - Fork 13
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
Is it possible to insert a comment after a value? #38
Comments
I am also curious about this. Also i want to know how to add comments when building json object at runtime (not loading/parsing). So for example i have this code: const {stringify} = require('comment-json');
let obj = { name: "peter"; age: 20; };
// TODO: how to add comment before property "name" here before calling stringify ?
const str = stringify(obj); |
@blhoward2 @kaelzhang I found a wacky way to do this (ugly but working): obj[Symbol.for('before:name')] = [{type: 'LineComment', inline: false, value: 'my custom comment'}]; will stringify to: {
// my custom comment
name: "peter";
age: 20;
}; |
I have a similar use case but the comment i wanted for entries in a list I have this
And I want to have this
I wrote the following code
I used util.inspect to looks at the object, which looked correct to me.
But the output from stringify didn't have the new comment.
|
After a json has been parsed, is it possible to insert a new comment that will then be retained? If so, how? I'm pulling my hair out...
The text was updated successfully, but these errors were encountered: