将嵌套和递归结构序列化为带有引用的平面结构
澄清:这是一种软件标识(我不知道这里是否允许)
不久前,我看到一个应用程序,它利用 javascript 库将嵌套对象转换为平面对象,如下所示
var a = {
attr1: "some value",
attr2: new Date(),
b: {
attr1: "some other value",
}
}
a.b.a = a
transform(a)
/*
[{
ref: 0,
attr1: {
type: "string",
value: "some value"
},
attr2: {
type: "Date",
value: "2022-03-09T16:17:03.216Z"
},
b: {
type: "ref",
value: "1"
}
},{
ref: 1,
attr1: {
type: "string",
value: "some other value"
},
b: {
type: "ref",
value: "0"
}
}]
*/
有谁知道这样做的库或标准吗?
clarification: this is a kind of software identification (and I dont know if it is allowed here)
A time ago I saw an app which has made use of a javascript library for transform nested objects into flat one like this
var a = {
attr1: "some value",
attr2: new Date(),
b: {
attr1: "some other value",
}
}
a.b.a = a
transform(a)
/*
[{
ref: 0,
attr1: {
type: "string",
value: "some value"
},
attr2: {
type: "Date",
value: "2022-03-09T16:17:03.216Z"
},
b: {
type: "ref",
value: "1"
}
},{
ref: 1,
attr1: {
type: "string",
value: "some other value"
},
b: {
type: "ref",
value: "0"
}
}]
*/
Does anyone know of a library or standard for do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论