hjson / hjson-js

Hjson for JavaScript
https://hjson.github.io/
MIT License
416 stars 49 forks source link

Add option for stringifying undefined members #28

Closed koliyo closed 7 years ago

koliyo commented 7 years ago

It would be useful to have the option of not including undefined members in the serilaized string. Eg

{
  foo: 1
  bar: undefined
}

vs

{
  foo: 1
}
laktak commented 7 years ago

So what would you use this for?

Also undefined is a JavaScript only thing. How would you deserialize this with Python, Java, C#, etc.?

koliyo commented 7 years ago

I was using it in combination with deep-object-diff, where missing members are marked as undefined. When these were removed from the output I missed some information in my object diffs. But I have a workaround for this now.

It is kind of a special case I understand, and not really suited for cross-environment communication.

olsonpm commented 11 months ago

I got here after being surprised with 'undefined' in the output after deleting a property. My use-case is updating a config file. i.e. read config -> update config -> write config. After updating the config to delete a property, it still shows up in the written output which I don't expect. I would expect this to behave like regular json.

Not sure why this issue isn't suited for cross-environment communication ?