epoberezkin / fast-json-stable-stringify

Deterministic JSON.stringify() - a faster version of @substack's json-stable-strigify without jsonify.
Other
285 stars 34 forks source link

Consider accepting a `space` option. #5

Closed wtgtybhertgeghgtwtg closed 5 years ago

wtgtybhertgeghgtwtg commented 5 years ago

One feature that is lost in the transition from json-stable-stringify to fast-json-stable-stringify is the space option. It may be a performance hiccup, but including it would allow easier transition from projects that use json-stable-stringify.

epoberezkin commented 5 years ago

The main use case for this package is to create the same string from the deep-equal objects to be used as a key - in this case the space option is NOT needed (and it only impacts performance).

If the object is stringified for the presentation the normal JSON can be used, can't it?

wtgtybhertgeghgtwtg commented 5 years ago

This was mostly raised for webpack use, but they decided to go in another direction. Sorry for the bother.

retorquere commented 4 years ago

I'd still be interested in this. It is correct that I want stable JSON for (test comparisons), but I also need them to be human-readable.

rileyjshaw commented 3 years ago

The main use case for this package is to create the same string from the deep-equal objects to be used as a key - in this case the space option is NOT needed (and it only impacts performance).

If the object is stringified for the presentation the normal JSON can be used, can't it?

@epoberezkin I’m not sure how representative this is, but my use case also requires space. I dynamically create a large object from scraped content, and check it into source control. Diffs are huge if the saved JSON is a single line. They are usually a single line with a stable property order… but I need to pass in space for that to work.

i-am-the-slime commented 3 years ago

Same here, I stable stringify to see diffs in my tests. I don't want to look at one line JSON files.