fast-json-stringify icon indicating copy to clipboard operation
fast-json-stringify copied to clipboard

Use fast-json-escape for string serialization

Open ivan-tymoshenko opened this issue 2 years ago • 2 comments

Prerequisites

  • [X] I have written a descriptive issue title
  • [X] I have searched existing issues to ensure the issue has not already been raised

Issue

@BridgeAR has a nice fast-json-escape package that allows you to escape string for JSON format. It's a better implementation than ours because it doesn't have a fallback to the standard JSON.stringify that we have here. However, we need to add some adjustments to support surrogate pairs escaping. @BridgeAR already has an implementation like we need this.

I created a PR a few months ago, but it's still awaiting a response.

@mcollina What is the correct solution in this case? Should we copy the code and put in a license? From the other point of view, the code I want to copy is not a fresh idea. It's a strict implementation of the JSON spec.

ivan-tymoshenko avatar Feb 26 '23 12:02 ivan-tymoshenko

I just released v2.0.0 that supports surrogate pairs. While checking the code, I noticed that the JSON.stringify got much faster escaping strings by now than in Node.js versions <= 10. It is now better to use JSON.stringify directly for escaping values, in case that's needed for the string.

BridgeAR avatar Feb 28 '23 21:02 BridgeAR

That you for releasing a new version and for the hint. I will check the default JSON.stringify performance for this case.

ivan-tymoshenko avatar Mar 01 '23 09:03 ivan-tymoshenko