Skip to content

Conversation

@iamdoron
Copy link
Contributor

@iamdoron iamdoron commented May 2, 2016

afterstable

instead of:
beforestable

@Marsup
Copy link
Contributor

Marsup commented May 2, 2016

This won't work with a circular object.

@iamdoron
Copy link
Contributor Author

iamdoron commented May 2, 2016

what do you mean by 'this won't work'? It should act the same as before (all tests have passed)

@Marsup
Copy link
Contributor

Marsup commented May 2, 2016

My bad, I thought json-stringify-safe was more clever than it really is.

@iamdoron
Copy link
Contributor Author

iamdoron commented May 2, 2016

Yes, it just outputs "[Circular]".


internals.stringify = (obj, serializer, indent, decycler) => {

return StableStringify(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just do StableStringify(obj, { space: indent, replacer: StringifySafe.getSerialize(serializer) }) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we can 👍
I changed it

@arb
Copy link
Contributor

arb commented May 2, 2016

I would maybe recommend "fast-safe-stringify" as an alternative since I think it's the fastest one out that that doesn't crash on circular references.

@iamdoron
Copy link
Contributor Author

iamdoron commented May 2, 2016

@arb - using @Marsup suggestion, it is better to use StringifySafe.getSerialize(), as it can be composed with StableStringify seamlessly. There's no such interface in fast-safe-stringify

@geek geek added the feature New functionality or improvement label May 2, 2016
@geek geek added this to the 10.4.0 milestone May 2, 2016
@geek geek self-assigned this May 2, 2016
@geek geek merged commit 71c2187 into hapijs:master May 2, 2016
@geek
Copy link
Member

geek commented May 2, 2016

@iamdoron well done, this will be a nice improvement for our console reporter.

@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

feature New functionality or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants