Accessing objects in JSON
Now that we understand how to make a script call to fetch an external JavaScript file, let us use the same technique to import a JSON feed. I have generated a test employee
JSON data feed with 100 records. To traverse through any JSON feed, it is important to make a note of how the data is arranged. The keys in this data feed are basic employee information such as employee number, date of birth, first name, last name, gender, hire date, titles that they have held, and the dates during which they have held those titles. A few employees have held the same title throughout their tenure, while there are some employees who have held more than one title.
Note
This JSON file will be part of the code files for exercises.
As we are dealing with a complex JSON data feed, let us save the data feed to a file. In the data_json_feed.html
file, we have imported the data.json
file, which is in the same folder as the HTML file. It is noteworthy that the JSON feed has been assigned...