Int Web Dev - Week 8 Questions and Coding Problems

Question 1

What is JSON?

JSON literally stands for JavaScript Object Notation, which allows for data from code to be permanently saved into a formatted file and easily interpreted by other developers or programs that use the file.

Question 2

What are some rules for encoding data in JSON format? BTW - Here's a really good overview of JSON.

Data must be in pairs of names and values, separated by commas, the objects must be contained within curly braces ({object}), and arrays of information must be stored in square brackets. The names must be contained within double quotes ("name"), whereas the values can be contained how they would by default, such as numbers just being the numbers, strings being in double quotes, etc.

Question 3

What method of the JSON API would you use to convert an array of objects into a JSON string?

JSON.stringify(objectArray);

Question 4

What method of the JSON API would you use to convert a JSON encoded string into an array of objects?

JSON.parse(objectArray.json);

Question 5

What does it mean to encode data? Other than JSON, what are some common ways to encode data?

Data encoding is essentially converting data to a form that allows it to be used by various different systems, so that if I create and then save an object on my windows in, say, java, then I should be able to deliver that saved object to another system, maybe mac, then they should be able to use python to be able to decode that data to be usable within that language.
There are various methods outside of JSON to accomplish this, the most immediately apparent being simple CSV, or Comma Separated Values. Another popular method is to encode into XML, which, if one is familiar with HTML, should be fairly familiar.
There are other methods of encoding data that can rely on the specific characters, such as familiar things like ASCII, Unicode, or utf-8, but those aren't necessarily the type of data encoding that's being asked about in this question.

Coding Problems

There are coding problems for you to do in the script element on the page.

Friend List (Problem 2)

Sale Details