我需要使用外键链接一些JSON。例如,我有三个JSON:
JSON 1 - 用户
{
id: 23,
name: "Agata"
}
JSON 2 - 幻灯片
{
title: "lalala",
content: "lalalalalal",
member: [
{
//here I would like to add json user id: 23
}
]
}
JSON 3 - 评论
{
title: "nanana",
author: // here I would like to add json user id : 23
}
你有什么想法吗?
答案 0 :(得分:1)
我在考虑你有三个包含每个JSON对象的变量,你可以这样做:
JSON 1 - 用户
var json1 = {
id: 23,
name: "Agata"
}
JSON 2 - 幻灯片
var json2 = {
title: "lalala",
content: "lalalalalal",
member: [
json1
]
}
JSON 3 - 评论
var json3 = {
title: "nanana",
author: json1
}