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

Add useToJSON option #64

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

juanjoDiaz
Copy link

This pull request add a new option to the library to force using the toJSON method of objects when it exits and it's the element is not a primitive (so it doesn't affect Dates). This allow to correctly flatten object as they would be if it was stringified to a JSON object using JSON.stringify. (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)

This PR fixes an issue in a downstream library that I'm having at the moment, related to mongodb's ObjectIDs being incorrectly flattened (zemirco/json2csv#175). However, I don't think that it's an isolated case. I believe it's a case common enough to have this extra option.

The PR contains unit test coverage for the change. Please let me know if everything is ok or if I need to do anything else.

@juanjoDiaz
Copy link
Author

I just noticed that this tackle the same use case as #61 . However, I think that this is much simpler.
In any case, either solution would work for me.

@knownasilya
Copy link

Just wanted to get this on someones radar

@antony
Copy link

antony commented Dec 11, 2017

@knownasilya @juanjoDiaz I've decided to fork and republish as I get the feeling that this project is abandoned.

I've re-released as flatley. Feel free to open PR there if I've missed anything from yours.

https://www.npmjs.com/package/flatley
https://www.github.com/antony/flatley

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

Successfully merging this pull request may close these issues.

3 participants