Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何在 JSON 中序列化以下对象? #540

Open
Rashomon511 opened this issue Jul 11, 2019 · 0 comments
Open

如何在 JSON 中序列化以下对象? #540

Rashomon511 opened this issue Jul 11, 2019 · 0 comments

Comments

@Rashomon511
Copy link
Owner

Rashomon511 commented Jul 11, 2019

const a = {
key1: Sysmnol(),
key2: 0
}
// 这个过程中发生了什么
console.log(Json.stringify(a))

返回{"key2":0}
image
所以stringify并不能将所有的数据类型在不丢失信息的情况下转换成字符串,上面的Map就在转换的过程中变成了一对{},解决方法就是用stringify可处理的数据结构替换Map

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant