- Learning Node.js Development
- Andrew Mead
- 282字
- 2021-06-30 18:56:56
JSON
Now that you know how to parse command-line arguments using process.argv and yargs, you've solved the first piece to the puzzle for the notes application. Now, how do we get that unique input from the user? The second piece to the puzzle is to solve how we store this information.
When someone adds a new note, we want to save it somewhere, preferably on the filesystem. So the next time they try to fetch, remove, or read that note, they actually get the note back. To do this, we'll need to introduce something called JSON. If you're already familiar with JSON, you probably know it is super popular. It stands for JavaScript Object Notation, and it's a way to represent JavaScript arrays and objects using a string. Now, why would you ever want to do that?
Well, you might want to do that because strings are just text, and that's pretty much supported anywhere. I can save JSON to a text file, and then I can read it later, parse it back into a JavaScript array or object, and do something with it. This is exactly what we'll take a look at in this section.
To explore JSON and how it works, let's go ahead and make a new folder inside our project called playground.
In the playground folder, we'll make a file called json.js, this is where we can explore how JSON works. To get started, let's make a very simple object.
- 計(jì)算機(jī)網(wǎng)絡(luò)與通信(第2版)
- 數(shù)據(jù)通信網(wǎng)絡(luò)實(shí)踐:基礎(chǔ)知識(shí)與交換機(jī)技術(shù)
- 光網(wǎng)絡(luò)評(píng)估及案例分析
- 5G承載網(wǎng)網(wǎng)絡(luò)規(guī)劃與組網(wǎng)設(shè)計(jì)
- Microsoft Dynamics CRM 2011 Applications(MB2-868) Certification Guide
- CCNP TSHOOT(642-832)認(rèn)證考試指南
- 5G技術(shù)與標(biāo)準(zhǔn)
- TD-LTE無(wú)線網(wǎng)絡(luò)規(guī)劃與設(shè)計(jì)
- 語(yǔ)音信號(hào)處理及Blackfin DSP實(shí)現(xiàn)
- 局域網(wǎng)組成實(shí)踐
- 轉(zhuǎn)化:提升網(wǎng)站流量和轉(zhuǎn)化率的技巧
- 現(xiàn)代通信系統(tǒng)(第5版)
- 精通SEO:100%網(wǎng)站流量提升密碼
- Building RESTful Web Services with .NET Core
- Building Microservices with Spring