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

hjson.stringify() ignores 'toJSON()' methods #38

Open
depeele opened this issue Jul 12, 2018 · 3 comments
Open

hjson.stringify() ignores 'toJSON()' methods #38

depeele opened this issue Jul 12, 2018 · 3 comments

Comments

@depeele
Copy link

depeele commented Jul 12, 2018

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();
}
@laktak
Copy link
Member

laktak commented Sep 14, 2018

Sorry, this project is EOL, see https://hjson.org

@retorquere
Copy link

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?

@dqsully
Copy link
Member

dqsully commented Feb 9, 2019

This project isn't EOL, but we are looking for contributors. See hjson/hjson#84

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

4 participants