We'll be using a file represented as JSON for this assignment. JSON is a standard for formatting data, and it's a common format you'll see throughout your web development career. Even more important will be parsing JSON.
This large object is in the products js file. It is the kind of object you would really recieve from google shopping.
Create a script.js file and an index.html file with the same boiler plate code as before. Copy the products.js file into that directory. In the html file, include the script products.js. Write your code in your script.js file.
Use the product search result in your file to find the following results. Note that you may want to comment out your solutions as you solve them, to avoid a mess of output in the console.
1.) Go through the items
and find all results that have kind
of shopping#product
. Print the count of these results. Where else is this count information stored in the search results?
2.) Print the title
of all items with a backorder
availability in inventories
.
3.) Print the title
of all items with more than one image link.
4.) Print all "Canon" products in the items (careful with case sensitivity).
5.) Print all items
that have an author name of "eBay" and are brand "Canon".
6.) Print all the products with their brand, price, and an image link
- We'll be dealing with large JSON objects quite frequently throughout the course. Use a Chrome extension such as JSONView in order to easily collapse arrays and objects during this assignment. Once the extension is installed, access the JSON file via Github by going to products.json, then clicking Raw right above the file.
- When in doubt, think about the different functions available for strings, objects, and arrays.
- Double-check your results, especially with #5
- Documentation
- All content is licensed under a CC-BY-NC-SA 4.0 license.
- All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact [email protected].