Kivylius Kivylius - 7 months ago 19
Javascript Question

How to store multiple records in JSON

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).

Here my code:

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

Answer

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:...",
}]