hjson-js
hjson-js copied to clipboard
hjson.stringify() ignores 'toJSON()' methods
IT would be nice if hjson honored toJSON() in a way consistent with the standard JSON.stringify().
From Mozilla Docs
If an object being stringified has a property named toJSON whose value is a function, then the toJSON() method customizes JSON stringification behavior: instead of the object being serialized, the value returned by the toJSON() method when called will be serialized. JSON.stringify() calls toJSON with one parameter:
- if this object is a property value, the property name
- if it is in an array, the index in the array, as a string
- an empty string if JSON.stringify() was directly called on this object
This could be accomplished by adding the following prior to hjson-stringify.js line 316:
if (typeof(value.toJSON) === 'function') {
value = value.toJSON();
}
Sorry, this project is EOL, see https://hjson.org
That page links back here (via npm) and doesn't mention this project being EOL. What does the project being EOL mean in practice? Just that the spec is frozen and so this lib is frozen, but any bugs found will be fixed? Or is no activity going to happen on this lib at all?
This project isn't EOL, but we are looking for contributors. See hjson/hjson#84