- 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.
- Hands-On Chatbot Development with Alexa Skills and Amazon Lex
- Windows Server 2003 Active Directory Design and Implementation: Creating, Migrating, and Merging Networks
- 物聯網時代
- 網絡安全技術與解決方案(修訂版)
- 正在爆發的互聯網革命
- 中小型局域網組建、管理與維護實戰
- 區塊鏈輕松上手:原理、源碼、搭建與應用
- jQuery Mobile Web Development Essentials
- 夢工廠之材質N次方:Maya材質手冊
- 4G小基站系統原理、組網及應用
- 現代通信系統(第5版)
- Laravel Application Development Cookbook
- 趣話通信:6G的前世、今生和未來
- Migrating to Drupal7
- 結網@改變世界的互聯網產品經理(修訂版)