久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Electron 中保存 JSON

Saving JSON in Electron(在 Electron 中保存 JSON)
本文介紹了在 Electron 中保存 JSON的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在使用 Electron 構建一個應用程序.在這個應用程序中,我正在使用 JSON 構建數據結構.我的數據結構如下所示:

I am building an app using Electron. In this app, I am building a data structure using JSON. My data structure looks like this:

{
  items: [
    { id:1, name:'football' },
    { id:2, name:'soccer ball' },
    { id:3, name:'basketball' }
  ]
}

我想將此 JSON 保存到名為data.json"的文件中.我想將其保存到文件中,因為我想在下次應用程序啟動時加載.我的挑戰是,我不知道如何保存數據.事實上,我什至不確定應該將文件保存在 哪里.我是否將其保存在與應用程序相同的目錄中?或者我應該使用一些跨平臺的方法嗎?

I want to save this JSON to a file called "data.json". I want to save it to a file because I want to load the next time the application starts. My challenge is, I do not know how to save the data. In fact, I'm not sure where I should even save the file. Do I save it in the same directory as the app? Or is there some cross-platform approach I should use?

目前,我有以下內容:

saveClick: function() {
  var json = JSON.stringify(this.data);
  // assume json matches the JSON provided above.
  // Now, I'm not sure how to actually save the file.
} 

那么,我如何/在哪里將 JSON 保存到本地文件系統以供以后使用?

So, how / where do I save JSON to the local file system for use at a later time?

推薦答案

Electron 缺乏一種簡單的方法來持久化和讀取應用程序的用戶設置.electron-json-storage 實現了一個類似于 localStorage 的 API根據 app.getPath('userData') 的定義,在操作系統應用程序數據目錄中寫入和讀取 JSON 對象.

Electron lacks an easy way to persist and read user settings for your application. electron-json-storage implements an API somehow similar to localStorage to write and read JSON objects to/from the operating system application data directory, as defined by app.getPath('userData').

這篇關于在 Electron 中保存 JSON的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機器人提及發出該機器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復必須使用導入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務器時的歡迎消息)
主站蜘蛛池模板: 久久精品久久久久 | 少妇视频在线观看 | 亚洲一区二区在线免费观看 | av最新网址| 日本国产精品 | 久久视频这里只有精品 | 91视频播放| 一级片在线视频 | 日日夜夜狠狠干 | 日韩视频在线观看 | 日本精品网站 | 一级黄色大片 | 奇米狠狠干| 日韩毛片免费看 | 亚洲激情视频在线 | 精品欧美一区二区精品久久 | 国产精品偷乱一区二区三区 | 亚洲视频一区二区三区四区 | 理论片中文字幕 | 国产精品视频免费 | 成人福利在线观看 | 亚洲免费视频网站 | 男女啪啪免费网站 | 日本不卡免费 | 九九视频在线 | 成人国产在线观看 | 国产精品久久久久久久久久久久久 | 国产一二三| 性色av网站| 91手机看片 | 青青草在线免费视频 | 欧美激情视频一区二区 | 亚洲aaaaaa | 成人欧美一区二区三区黑人免费 | 免费观看毛片 | 激情网站在线观看 | 中文字幕在线播放视频 | 午夜视频免费在线观看 | 中文字幕亚洲一区 | 国产日韩精品一区二区 | 亚洲一区二区免费视频 |