I need a data structure to store feeds in columns into tabs.
So the pseudo structure would be:
First Tab : name (string)
First column
First feed : (url (str), type (str), limit (int))
Second feed : (url (str), type (str), limit (int))
Second column
First feed : (url (str), type (str), limit (int))
Second feed : (url (str), type (str), limit (int))
Third feed : (url (str), type (str), limit (int))
Second Tab : name (string)
First column
First feed : (url (str), type (str), limit (int))
Second column
First feed : (url (str), type (str), limit (int))
... And so on.
Now this works:
var feeds = [
{"groupName":"News",
"0": [
{"url":"http://xkcd.com/rss.xml","type":"mixed","limit": 8},
{"url":"http://xkcd.com/rss.xml","type":"photo","limit": 4}
],
"1": [
{"url":"http://xkcd.com/rss.xml","type":"mixed","limit": 8},
{"url":"http://xkcd.com/rss.xml","type":"mixed","limit": 8},
{"url":"http://xkcd.com/rss.xml","type":"photo","limit": 4}
]
},
{"groupName":"Comics",
"0": [
{"url":"http://xkcd.com/rss.xml","type":"photo","limit": 8},
{"url":"http://superphazed.tumblr.com/rss","type":"photo","limit": 8}
]
}
];
But
- I want to avoid maintaining a numerical index for the column keys ;
- I'm not sure it's the right data structure type.
Apparently the form above is a JavaScript literal object, that is, not an array and not JSon. This is a problem, I want to use the right data structure for what I intend to do with it : At one point in time, I need to validate variables against this data structure, that is to say "OK, this variable is a proper list of feeds". I also need to easily add, delete and rename elements, and from what I can see, there are at least 3 approaches to "arrays" in JavaScript, each with its own set of idiosyncrasies, methods and tools, dos and don'ts ; The context is JavaScript (module pattern) in the browser, and JQuery is
available.
So I guess my question is twofold:
- What is the best data structure in this context to allow easy manipulation later ;
- Is there a way to have unnamed columns containing non-indexed feeds?
columns
property to the group entity and use a real array there?feeds = { groupName: "News", columns: [ [ {url, type, limit } ], [ {url, type, limit} ] ] }
\$\endgroup\$duplicate key: 'groupName'
and BTW I'm having a hard time understanding this one: Duplicate key? Of course I want to duplicate keys..? I must be missing something big, thanks a lot for helping. \$\endgroup\$