Note that there are some explanatory texts on larger screens.

plurals
  1. POCorrect layout for Json data when searching different attributes
    primarykey
    data
    text
    <p>I have created a data file using JSON. The data is a selection of variables about tube stations. See below for a section of the file. This setup works very well for finding stations when you have the station id. example: when you click on a station on my webpage the elements id is the station code and this allows a popup box to be filled with the stations name and zone.</p> <p>However, how would it be best to find the location of the station when for example given the full text name? a) I would have to have a code iterating through every station object and using an if command check the name in the object against the name given. b) created a set of key:value pairs in a second javascript object which is first used to lookup the station id then searches in the first object for the rest of the station data.</p> <p>Also how would I find data on all the stations on a given line. a) iterate through and check for each that the tubelines array contains the line string b) Yet another object containing all station codes under a line heading.</p> <pre><code>{ "BST": { "name": "Baker Street", "Location": [ 51.523129639184, -0.15688978273689 ], "zone": 1, "tubelines": [ "Bakerloo", "Circle", "Hammersmith &amp; City", "District" ], "Bakerloo": { "stepfreetrain": false }, "Circle": { "stepfreetrain": false }, "Hammersmith &amp; City": { "stepfreetrain": false }, "District": { "stepfreetrain": false } }, "CHX": { "name": "Charing Cross", "Location": [ 51.508358644804, -0.12478853109718 ], "zone": 1, "tubelines": [ "Bakerloo", "Northern" ], "Bakerloo": { "stepfreetrain": true }, "Northern": { "stepfreetrain": true } } } </code></pre> <p>So the key question is, is this the best way to lay out the data above and if so which is the quickest method to pull out information?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload