DB Post 6

Three JSON Concepts

Parsing an Object with JSON Parse

JSON can be used to parse through Objects as long as they are in the proper syntax. The following line of JSON text can be parsed by JSON to return a JavaScript object:

'{"name" : "Joe", "make" : "Kia", "model" : "ForteLX", "year" : "2021"}'

Turning JavaScript objects into Strings with JSON Stringify

JSON can also be used to turn JavaScript objects into strings (the same format JSON is written in). Consider the prevoius line of text but written as a JavaScript object:

const obj = {name: "Joe", make: "Kia", model: "ForteLX", year:"2021"};

Parsing Dates with JSON

Dates need to be written as strings in JSON, but that is okay because parse can be used to convert it back into a date object. Consider the following line of JSON text that will be parsed to return a JavaScript object:

'{"name":"Joe", "birth":"1990-12-09", "city":"Bedford", "state":"Ohio"}'

Click Here for DB Post 1

Click Here for DB Post 2

Click Here for DB Post 3

Click Here for DB Post 4

Click Here for DB Post 5

Click Here for Midterm Project