如何在JSON中存储多个记录 [英] How to store multiple records in JSON

查看:808
本文介绍了如何在JSON中存储多个记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何在json文件(结构)中存储多个实体,我想通过id函数(JQuery/javascript)查找并轻松排序(0,1,2 ... 200).

I wan't to know how store multiple entities in json file (Structure) I will want to find by id functions (JQuery/javascript) and easy sorting (0,1,2...200).

这是我的代码:

{ 
    "id" : 5,
    "name" : "Jemmy overy",
    "data" : {...},
    "link" : "http:...",
}

推荐答案

顺便说一句,如果您希望通过它们的索引号将它们拉出,那么下面Lix的答案是最好的.

Btw, The answer by Lix below is best if you're looking to pull them out via their index number.

将它们包裹在方括号中!

Wrap them in square brackets!

[{ 
    "id" : 5,
    "name" : "Jemmy overy",
    "data" : {...},
    "link" : "http:...",
},
{ 
    "id" : 6,
    "name" : "John Smith",
    "data" : {...},
    "link" : "http:...",
}]

这篇关于如何在JSON中存储多个记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆