From the course: JSON Essential Training

Unlock the full course today

Join today to access over 24,000 courses taught by industry experts.

Solution: Process JSON data

Solution: Process JSON data - JavaScript Tutorial

From the course: JSON Essential Training

Solution: Process JSON data

(upbeat music) - [Instructor] My first step is to stringify the posts array. So I have this array, it contains objects and down here on line 17, I'm going to write code that stringifies it. So I'm going to create a variable first and I'm going to make that postsJson, and the value is going to be using JSON.stringify and passing it hosts. And so that is going to stringify my posts array. Now, I also want to stringify the article object, and again, it's pretty much the same code. I just need to use a different variable name. So I'm going to use const articleJson, and I'm going to use JSON.stringify, and I'm going to pass it article. So let me go ahead and check just to make sure these worked, I'm going to open up my HTML file for this blog.html, going to open that with my web server. So I've got the page loaded and down in my console, I can check postsJson and I indeed have stringified version of that variable.…

Contents