Closed mesqueeb closed 4 years ago
fast-json-stringify depends on fast-safe-stringify. With fast-json-stringify you need to stringify objects that match a predefined jsonschema describing that object to get a performance benefit. If you do that it’s faster than JSON.stringify. If the schema doesn’t match the object being serialised, fast-json-stringify falls back to fast-safe-stringify which will safely stringify object faster than json-safe-stringify.
So it depends on your use case, and benchmarks between the two packages wouldn’t make sense because they work on totally different operational parameters
@davidmarkclements thanks. I realise now fast-json-stringify is some completely different.
However, you say it depends on fast-safe-stringify
? Which doesn't seem the case looking at their package.json.
But I digress.
I'm now wondering if I should choose this package or regular JSON.stringify. I was wondering how much faster this package is?
When I looked at your benchmarks I saw you compare to other packages, but not to native JSON.stringify. 😅
Would you be willing to add the benchmarks of the native JSON.stringify compared to your package?
Thanks a lot!!
Oh actually I think it’s that fastify falls back to this so they’re rather used together.
It will be slower than JSON.stringify but if your object has circular references JSON.stringify on its own will fail.
This is fastest SAFE way to stringify
Fastify does not fallback to this anymore. Il 2 gen 2020, 07:09 +0200, David Mark Clements notifications@github.com, ha scritto:
Oh actually I think it’s that fastify falls back to this so they’re rather used together. It will be slower than JSON.stringify but if your object has circular references JSON.stringify on its own will fail. This is fastest SAFE way to stringify — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
I'm looking for a JSON stringify function and am doubting between these two packages:
Is it possible to add some comparison and/or benchmarks between these two?