How to reliably hash JavaScript objects?

前端 未结 6 1852
天涯浪人
天涯浪人 2021-02-06 21:53

Is there a reliable way to JSON.stringify a JavaScript object that guarantees that the ceated JSON string is the same across all browsers, node.js and so on, given that the Java

6条回答
  •  情话喂你
    2021-02-06 22:41

    You're asking for an implementation of something across multiple languages to be the same... you're almost certainly out of luck. You have two options:

    • check www.json.org implementations to see if they might be more standardized
    • roll your own in each language (use json.org implementations as a base and there should be VERY little work to do)

提交回复
热议问题